简体   繁体   中英

npm 8.5.5: unexected token in @npmcli\aborist

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

eg 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)

  • restarting my PC
  • uninstalling node 16.15 via nvm and reinstalling it

Workaround

  • delete the file C:\Users\xxx\AppData\Roaming\nvm\v16.15.0\node_modules\npm\node_modules\@npmcli\arborist
  • then copy the aborist directory from an older node version to that directory: eg from C:\Users\xxx\AppData\Roaming\nvm\v16.12.0\node_modules\npm\node_modules\@npmcli\arborist\

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

This worked for me:

  • updated nvm to version 1.1.9 (old installed version was 1.1.7 )
  • then reinstalled node version 16.15.0 (now aborist is a directory) and the commands work as expected

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM