npmnvmnpm-clinvm-windows

npm 8.5.5: unexected token in @npmcli\arborist


after upgrading npm (via nvm) to 8.5.5 npm commands do not work anymore:

e.g. npm --verbose ls webpack fails with:

npm verb stack C:\Users\marti\AppData\Roaming\nvm\v16.15.0\node_modules\npm\node_modules\@npmcli\arborist:1
npm verb stack ../../workspaces/arborist
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:1033:15)
npm verb stack     at Module._compile (node:internal/modules/cjs/loader:1069:27)
npm verb stack     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159: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\marti\AppData\Roaming\nvm\v16.15.0\node_modules\npm\lib\commands\ls.js:7:18)
npm verb stack     at Module._compile (node:internal/modules/cjs/loader:1105:14)
npm verb cwd D:\dev\xxx
npm verb Windows_NT 10.0.19043
npm verb argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "--verbose" "ls" "webpack"
npm verb node v16.15.0
npm verb npm  v8.5.5
npm ERR! Unexpected token '.'

Note: when I use nvm and switch back to node 16.12 (npm version 8.1.0) it works fine

Details

The file that the error refers to
C:\Users\xxx\AppData\Roaming\nvm\v16.15.0\node_modules\npm\node_modules\@npmcli\arborist contains only this (which is not valid js I guess):

../../workspaces/arborist

What I have tried (and did not work)

Workaround

Any ideas what I am doing wrong? Or is this just a bug in npm 8.5.5


Solution

  • This worked for me: