2

Since today I can't use any npm command.

Here's what I get everytime:

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

Error: Cannot find module 'C:\Users\Adrien\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

I use Windows 10. The commands for node work. I tried to uninstall Node.js, change the path in environment variables, but nothing changes...

Everything worked fine until I work on my new React.js project and got errors.

I have no npm folder in C:\Users\Adrien\AppData\Roaming\npm\node_modules

Thank you for your help.

renadr
  • 141
  • 1
  • 7

4 Answers4

7

Okay, so I solved my problem thanks to @LOTUSMS that answered to himself here.

In summary :

  1. Uninstall Node.js from Programs & Features.

  2. Reboot the computer.

  3. Delete every node and npm folders :

    • C:\Program Files (x86)\Nodejs
    • C:\Program Files\Nodejs
    • C:\Users\{User}\AppData\Roaming\npm (or %appdata%\npm)
    • C:\Users\{User}\AppData\Roaming\npm-cache (or %appdata%\npm-cache)
    • C:\Users\{User}\.npmrc (and possibly check for that without the . prefix too)
  4. Remove all npm or node references in the environment variable.

  5. "If it's still not uninstalled, type where node at the command prompt and you'll see where it resides -- delete that (and probably the parent directory) too."

  6. Reboot the computer

  7. Install Node.JS and NPM from beginning.

renadr
  • 141
  • 1
  • 7
1

Simply just restart your PC, refresh code editor and run the command.

0

The issue is due to wrong path of node in system variable. Please make sure that points to the right directory.

trizin
  • 285
  • 2
  • 11
  • I tried paths as : C:\Users\Adrien\AppData\Roaming\npm , C:\Program Files\nodejs\node_modules\npm and it's still not working. However NodeJS works. – renadr Mar 17 '19 at 13:59
0

Spent the past 24 hrs trying to resolve this and good now:

Go to settings - apps - node.js.

Here, two options prevail, 'modify' or 'unistall', select 'modify' and then press the 'repair' button which appears on the next dialogue window. Doing so will re-install a complete set of the files.

Go to PwerShell (Windows) or Bash (Mac) and type in 'npm -v', you should get a positive return, i.e., a display of the npm version number successfully installed.

I needed to resolve this as a pre-requisite to installing Truffle to support my Ethereum development environment.

AlBlue
  • 20,872
  • 14
  • 63
  • 85