Reputation: 830
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:
Upvotes: 7
Views: 19439
Reputation: 11
Write on your terminal or command prompt:
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
Enter your sudo password if applicable then run:
npm install -g nodemon
Your problem should be resolved, it worked in my case:
Upvotes: 0
Reputation: 459
Update to the latest nvm version 1.1.9 https://github.com/coreybutler/nvm-windows/releases
If using npm 16.16.0, you will still get the npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
but the npm ERR! Unexpected token '.'
won't break your npm install or running. However, using npm 18.6.0 will run everything fine.
Upvotes: 0
Reputation: 1087
FYI - updating to node v18.4.0 and npm v8.12.1 resolved this issue for me.
Upvotes: 0
Reputation: 15730
C:\Program Files\nodejs
npm.cmd
with notepad as adminprefix -g
with prefix --location=global
, and Savenpx.cmd
Check if it is fixed
If it is not working, try updating npm using npm install npm@latest -g
Upvotes: 6
Reputation: 1
I uninstall latest Nodejs and install Nodejs version 16.14.2 with this https://nodejs.org/dist/v16.14.2/node-v16.14.2-x64.msi
and that solved my error
Upvotes: 0
Reputation: 9
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.
Upvotes: 1
Reputation: 166
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.
Upvotes: 2