NPM:使用 nvm 在 Windows 10 上运行 npm -v 时找不到 npm-cli.js

sgr*_*lon 7 node.js npm nvm windows-10

nvm在 Windows 10 上使用,所以我安装节点 10.19.0:

nvm 安装 10.19.0

nvm 使用 10.19.0

节点 -v

v10.19.0
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

我看到我的C:\Program Files\nodejs\node_modules 文件夹,它是空的

如何修复我的 node+npm 安装?

我试试这个,但没有解决我的安装:

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 ...
Run Code Online (Sandbox Code Playgroud)

sgr*_*lon 14

mcAfee 阻止下载node_modules目录。

解决方法:

转到https://nodejs.org/dist/latest-v10.x/并下载 zip 文件

打开zip文件并复制node_module\npm进去C:\Users\foo\AppData\Roaming\nvm\v10.19.0\node_modules\npm

npm -v

6.13.4
Run Code Online (Sandbox Code Playgroud)