node.jsnpmcmdwindow

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js' when trying to run npm


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?


Solution

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

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