kalyklos
kalyklos

Reputation: 51

internal/modules/cjs/loader.js:905 npm error

My node works correctly but I have error when I run npm :

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: []
}
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'
←[90m    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)←[39m
←[90m    at Function.Module._load (internal/modules/cjs/loader.js:746:27)←[39m
←[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)←[39m
←[90m    at internal/main/run_main_module.js:17:47←[39m {
  code: ←[32m'MODULE_NOT_FOUND'←[39m,
  requireStack: []
}

At the third line there is a path, that path path is wrong.

The real path for npm-cli.js is : C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js

Besides, I tried to find loader.js in cjs directory, but didn't find it.

I tried to delete npm and npm-cache directories from Appdata/Roaming then uninstall and reinstall node, but I still have that problem (with npm only). How can I resolve this?

Upvotes: 2

Views: 3580

Answers (1)

Luiz Santos
Luiz Santos

Reputation: 26

I had a similar problem and tried two solutions: the first was to run the command rm -rf node modules && package-lock.json $$ npm install and I noticed that the error kept reading the information that was displayed on my vi terminal I was trying to run a command where the file didn't exist so I had to change the information in package.json in the script that I changed to the relative path of the file.

Upvotes: 1

Related Questions