Home > Blockchain >  Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm

Time:10-13

I am trying to run npm install from the cmd in a windows environment. The following error occurs:

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

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Is there a reason why \node_modules\npm\bin\ repeats within the file path? I've set the environmental variables to:

C:\Program Files\nodejs\node_modules\npm\bin

and to:

C:\Program Files\nodejs\

Is there a solution to fix this issue so that I can run the npm commands?

CodePudding user response:

Copy the directory named npm from your installed node path (In my case the npm directory was available in C:\Program Files\nodejs\node_modules).

Navigate to C:\Users\%USERNAME%\AppData\Roaming\npm\node_modules and paste the copied npm directory there.

this should work.

CodePudding user response:

Run this line in terminal and It should work ;-) Good Luck !

SET PATH=C:\Program Files\Nodejs;%PATH%
  • Related