When I follow the quickstart tutorial: and do “sudo npm start”
I get this error:
an@yan-VirtualBox:~/ICPDfinity/hello2$ sudo npm start
npm WARN npm npm does not support Node.js v10.19.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm You can find the latest version at https://nodejs.org/
> hello2_assets@0.1.0 prestart
> npm run copy:types
npm WARN npm npm does not support Node.js v10.19.0g Completed in 2ms
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm You can find the latest version at https://nodejs.org/
glob error { [Error: EACCES: permission denied, scandir '/root/.npm/_logs']
errno: -13,
code: 'EACCES',
syscall: 'scandir',
path: '/root/.npm/_logs' }
⸨⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⸩ ⠙ : timing npm:load:cleanupLog Completed in 2ms
> hello2_assets@0.1.0 copy:types
> rsync -avr .dfx/$(echo ${DFX_NETWORK:-'**'})/canisters/** --exclude='assets/' --exclude='idl/' --exclude='*.wasm' --delete src/declarations
sending incremental file list
⸨⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⸩ ⠹ : timing npm:load:cleanupLog Completed in 2ms
sent 304 bytes received 14 bytes 636.00 bytes/sec
total size is 19,126 speedup is 60.14
> hello2_assets@0.1.0 start
> webpack serve --mode development --env development
[webpack-cli] Unable to load '@webpack-cli/serve' commandeted in 2ms
[webpack-cli] TypeError: options.forEach is not a function
at WebpackCLI.makeCommand (/home/yan/ICPDfinity/hello2/node_modules/webpack-cli/lib/webpack-cli.js:108:21)
at ServeCommand.apply (/home/yan/ICPDfinity/hello2/node_modules/@webpack-cli/serve/lib/index.js:41:19)
at loadCommandByName (/home/yan/ICPDfinity/hello2/node_modules/webpack-cli/lib/webpack-cli.js:626:35)
at Command.program.action (/home/yan/ICPDfinity/hello2/node_modules/webpack-cli/lib/webpack-cli.js:1091:23)
at Command.listener [as _actionHandler] (/home/yan/ICPDfinity/hello2/node_modules/webpack-cli/node_modules/commander/index.js:922:31)
at Command._parseCommand (/home/yan/ICPDfinity/hello2/node_modules/webpack-cli/node_modules/commander/index.js:1503:14)
at Command.parse (/home/yan/ICPDfinity/hello2/node_modules/webpack-cli/node_modules/commander/index.js:1292:10)
at Command.parseAsync (/home/yan/ICPDfinity/hello2/node_modules/webpack-cli/node_modules/commander/index.js:1318:10)
at WebpackCLI.run (/home/yan/ICPDfinity/hello2/node_modules/webpack-cli/lib/webpack-cli.js:1123:28)
at runCLI (/home/yan/ICPDfinity/hello2/node_modules/webpack-cli/lib/bootstrap.js:11:19)
Does any of you have an idea to get me out of this please ?
In which tutorial did you find npm start? Shouldn’t it be dfx start?
When I try the IC locally generally it’s dfx start to start the network and in another prompt dfx deploy to deploy the app on the simulated local network.
That being said, still not explains why it its an old version of node. sudo which npm points to the same version as which npm?
sudo which npm
[sudo] password for yan:
/usr/local/bin/npm
yan@yan-VirtualBox:~$ sudo which npm
/usr/local/bin/npm
yan@yan-VirtualBox:~$ sudo npm -v
npm WARN npm npm does not support Node.js v10.19.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm You can find the latest version at https://nodejs.org/
8.0.0
yan@yan-VirtualBox:~$ sudo node -v
v10.19.0
Regarding npm issue, generally speaking it is a bad practice to use node/npm with sudo, therefore, instead of fixing the sudo npm command I would advice to try to run the commands with your user npm and then fix the potential errors there.
@YannickPezeu alright was I said above is not fully correct and I also got the same error. Here’s what I did and how I resolved it:
From a fresh project:
dfx new myproject
cd myproject
dfx start --background
dfx deploy
At this point, you can already test if you open http://canister-id.localhost:8000 in your browser
You can find the canister-id with the dfx command or in the file .dfx/local/canister_ids.json (the myproject_assets).
Then, I run npm run start, I get the error Unable to load '@webpack-cli/serve' command too!
To solve it, I installed a newer version of the webpack-cli
npm rm webpack-cli && npm i webpack-cli
Then I was able to run npm run start and open the app in the browser at the adress http://localhost:8080 and it was alright too
For anyone’s reference - you can submit changes to any page in our docs by clicking the pencil icon! Here’s my PR for this issue, but anyone can suggest a change like this, and tag me and / or Carsten