4

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
  • 345
  • 1
  • 2
  • 13

5 Answers5

2

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

1

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
  • 23,254
  • 14
  • 71
  • 91
KIASILI.io
  • 11
  • 1
  • Not entirely sure why I needed to repair it after installing the latest version but repairing worked. Thank you. – Tranzium Apr 10 '23 at 03:23
0

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

trizin
  • 347
  • 2
  • 13
  • 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

A quick solution is npm install -D npm. Although this is not a great solution because you need to set your workspace correctly. But, it works and you can use it on urgent basis. ;)

naeem1098
  • 123
  • 2
  • 9
0

if you struggle with the same probleme here how i personnaly solve it : Just open the configuration panel windows like if you want to uninstall node, but right clic and select repair

ZakariaOFC
  • 39
  • 2