0

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?

user1584421
  • 3,499
  • 11
  • 46
  • 86
  • According to this, the NodeJS version is `v10.19.0`. Can you confirm the version is not overridden in `package.json` file as done [here](https://stackoverflow.com/a/50798589/8244632)? – Lalit Fauzdar May 09 '22 at 19:54
  • @LalitFauzdar I do not have a package.json file. I just issued these commands on the terminal. – user1584421 May 09 '22 at 21:26
  • If it's not a project, then surely you've an old version of node. Try doing a fresh re-install after removing it. – Lalit Fauzdar May 10 '22 at 03:42
  • I uninstalled node succesfully, but for some reason node and npm remains and now everything works fine! It's like i had two versions of node on top of each other and everything kept crashing. I still am not sure what happened, but now everything works. – user1584421 May 10 '22 at 17:55

1 Answers1

1

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/