npm install fails with npm ERR! Unexpected token '.'
Error
npm install -g yarn
npm ERR! Unexpected token '.'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Domino\AppData\Local\npm-cache\_logs\2022-03-25-debug-0.log
Error with verbose on
(...)
npm verb stack C:\Users\Domino\AppData\Roaming\nvm\v16.14.2\node_modules\npm\node_modules\libnpmfund:1
npm verb stack ../workspaces/libnpmfund
npm verb stack ^
npm verb stack
npm verb stack SyntaxError: Unexpected token '.'
npm verb stack at Object.compileFunction (node:vm:352:18)
npm verb stack at wrapSafe (node:internal/modules/cjs/loader:1032:15)
npm verb stack at Module._compile (node:internal/modules/cjs/loader:1067:27)
npm verb stack at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
npm verb stack at Module.load (node:internal/modules/cjs/loader:981:32)
npm verb stack at Function.Module._load (node:internal/modules/cjs/loader:822:12)
npm verb stack at Module.require (node:internal/modules/cjs/loader:1005:19)
npm verb stack at require (node:internal/modules/cjs/helpers:102:18)
npm verb stack at Object.<anonymous> (C:\Users\Domino\AppData\Roaming\nvm\v16.14.2\node_modules\npm\lib\utils\reify-output.js:16:38)
Solution
This is due to a bug introduced in nvm 1.1.8.
It fails to ask for the windows elevated permission prompt (UAE).
The solution is either to downgrade to nvm 1.1.7, or enable Windows feature "Developer Mode" to ON.
The solution is to upgrade to nvm 1.1.10 where the elevated permission prompt is restored !
Problem #1 - exit status 5: Access is denied.
PS C:\dev\react-scss-jest-typescript> nvm uninstall 16.14.2
Uninstalling node v16.14.2...exit status 5: Access is denied.
This is another variation of the same bug.
I tried this and was not happy with the results as it would only partially fix the issues. So I don't recommend it:
$ Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
How to Install nvm
Latest installer for Windows: https://github.com/coreybutler/nvm-windows/releases
Latest installer for Linux/Mac: https://github.com/nvm-sh/nvm#install--update-script
Some people having same issues
https://github.com/npm/cli/issues/4234
https://github.com/npm/cli/issues/4234
https://stackoverflow.com/questions/70852727/unknown-error-on-npm-install-npm-err-unexpected-token-on-using-nvm-window
Recent Comments