user1584421
user1584421

Reputation: 3843

Cannot install npm packages although i have latter version of node

I want to install typescript with npm - sudo npm i -g typescript. I got back this:

npm does not support Node.js v10.19.0
You should probably upgrade to a newer version of node as we
can't make any promises that npm will work with this version.
You can find the latest version at https://nodejs.org/
/usr/local/lib/node_modules/npm/lib/npm.js:32
  #unloaded = false
  ^

SyntaxError: Invalid or unexpected token
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at module.exports (/usr/local/lib/node_modules/npm/lib/cli.js:22:15)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:2:25)
    at Module._compile (internal/modules/cjs/loader.js:778:30)

I checked the versions for both node and npm. For node i have v16.14.0 and for npm i have 8.9.0.

Anyway, i followed the procedure to update node with these commands:

sudo npm cache clean -f
sudo npm install -g n
sudo node latest

But for every command, i got back the exact same error posted above. So it seems i am stuck. Any ideas?

Upvotes: 0

Views: 495

Answers (1)

Arthur Medeiros
Arthur Medeiros

Reputation: 130

Are you using NVM? Because it seems that you npm version is not compatible with you node version.

I only got a similar error, when running an older node version with a newer npm version

ERROR: npm is known not to run on Node.js v10.19.0
You'll need to upgrade to a newer Node.js version in order to use this
version of npm. You can find the latest version at https://nodejs.org/

Upvotes: 1

Related Questions