Quickstart Error: npm does not support Node.js v10.19.0

Hi, I’m on Ubuntu 20.04 in Virtualbox,

npm -v
8.1.1
node -v
v14.18.1

When I follow the quickstart tutorial: and do “sudo npm start”
I get this error:

[email protected]:~/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/

> [email protected] 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
> [email protected] 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

> [email protected] 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 ?

1 Like

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?

1 Like

I found it in this tutorial: Local development :: Internet Computer

Thanks you are right,

sudo which npm
[sudo] password for yan: 
/usr/local/bin/npm
[email protected]:~$ sudo which npm
/usr/local/bin/npm
[email protected]:~$ 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
[email protected]:~$ sudo node -v
v10.19.0

What do you suggest me to do please ?

Update: see Quickstart Error: npm does not support Node.js v10.19.0 - #5 by peterparker

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.

dfx itself might need sudo though, this is how I fixed it on my osx (Permissions on OSX - #2 by peterparker)

P.S.: you can also try to generally upgrade node on your machine, current LTS version is v14 but yep, again, better to run it with your user.

2 Likes

@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

3 Likes

Wow ! You nailed it ! Thanks a lot !
Shouldn’t this be added to the quickstart tutorial ?

Is it ok for me to say Thank you or we keep it in StackOverflow style ?

1 Like

Très cool, happy to hear it worked out.

We can probably leave it as it is, just mark the question as answered.
Hopefully they will fix the issue in the next version of their sample app.

Have fun :call_me_hand:

1 Like

That error doesn’t even come from us - it sounds like npm encourages you to upgrade. For agent-js, we specify

"engines": {
    "node": "^12 || ^14 || ^16",
    "npm": "^7.17"
  },

in the package.json, so we could at least specify the node engine at 12, since it’s the minimum that we test in our CI

1 Like

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

The error about nodejs indeed but, the webpack error is in the package.lock of the sdk: npm start fails due to "options.forEach is not a function" · Issue #1870 · dfinity/sdk · GitHub