NPM: npm-cli.js not found when running npm -v on Windows 10 with nvm

Viewed 6754

I use nvm on Windows 10 so I install node 10.19.0:

nvm install 10.19.0

nvm use 10.19.0

node -v

v10.19.0

npm -v

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
PS C:\workspace\my-front>

I see my C:\Program Files\nodejs\node_modules folder and it is empty.

How to repare my node+npm installation?

I try this but not solve my installation:

PS C:\workspace\my-front> nvm uninstall 10.16.0
Uninstalling node v10.16.0... done
PS C:\workspace\my-front> nvm list

    8.9.2
PS C:\workspace\my-front> nvm install 10.19.0
Downloading node.js version 10.19.0 (64-bit)...
Complete
Creating C:\Users\foo\AppData\Roaming\nvm\temp

Downloading npm version 6.13.4... Complete
Installing npm v6.13.4...

Installation complete. If you want to use this version, type

nvm use 10.19.0
PS C:\workspace\my-front> nvm use 10.19.0
Now using node v10.19.0 (64-bit)
PS C:\workspace\my-front> node -v
v10.19.0

C:\workspace\my-front> npm -v
internal/modules/cjs/loader.js:638 ...
2 Answers

mcAfee block download of node_modules directory.

Workaround:

go to https://nodejs.org/dist/latest-v10.x/ and download zip file

open zip file and copy node_module\npm in C:\Users\foo\AppData\Roaming\nvm\v10.19.0\node_modules\npm

npm -v

6.13.4

I had the same issue. I solved it by disabling McAfee while doing nvm installations

Related