npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! Unexpected token '.'
Everything was working well in my machine. but suddenly npm/npx started throwing the above error.
I'm getting the same error for every npm commands.
system config:
OS: Windows 10
Node V : v16.15.1
npm v : 8.11.0
I have tried below solutions so far:
- npm cache clean --force (throwing the same error)
- ran commands with --location=global
- modified npm and npm.cmd file by replacing prefix -g with prefix --location=global
CodePudding user response:
This is a reported issue in NPM, so your best chance is to update it to an earlier (the issue is also reported at 8.3.1) or latest version. And if you're using NVM for Windows with the version below 1.1.9 you could see this problem with any version of Node, so you should update your NVM version too.
CodePudding user response:
I installed version 16.14.2 of NodeJS and not the latest one. It solved the issue after two days of pulling out my hair. I hope this helps.