Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 ...
like image 225
Stéphane GRILLON Avatar asked Feb 26 '20 10:02

Stéphane GRILLON


People also ask

How do I install npm with NVM?

It can be installed manually, if you prefer. Open the terminal and run the nvm list available command to see a list of Node versions that are available to download and install. Run the nvm use command, followed by the version number of Node you want to use (e.g. nvm use 16.9. 1 ) to use a specific version.

Why npm command is not working on CMD?

The Npm command not found error can appear when you install or upgrade npm. On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.

Why it is showing npm is not recognized?

The error “npm is not recognized as an internal or external command” error may occur because either the npm is not installed or it is not added to the windows path. To resolve this error, the first solution is to install Node. js on Windows as Node. js is equipped with npm by default.


1 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
like image 108
Stéphane GRILLON Avatar answered Oct 17 '22 15:10

Stéphane GRILLON