Npm install does not work in Windows PowerShell

So my problem is this. I have a project with a package. Json When I run "npm install" on the command line (cmd.exe), everything installs as expected. However, when I do the same in PowerShell (powershell.exe), I get the error: "npm ERR! Error: ENOENT, open" c: \ package.json ", although I ran" npm install "on the project path It is always looking for package.json in c: for some reason I can not understand.

Below is npm-debug.log (which I also wrote c: although my path is: c: \ code \ myProject):

0 info it worked if it ends with ok 1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe', 1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli 'install' ] 2 info using npm@1.3.11 3 info using node@v0.10.21 4 verbose node symlink C:\Program Files\nodejs\\node.exe 5 error install Couldn't read dependencies 6 error Error: ENOENT, open 'c:\package.json' 7 error If you need help, you may report this log at: 7 error <http://github.com/isaacs/npm/issues> 7 error or email it to: 7 error < npm-@googlegroups.com > 8 error System Windows_NT 6.2.9200 9 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" 10 error cwd c:\ 11 error node -v v0.10.21 12 error npm -v 1.3.11 13 error path c:\package.json 14 error code ENOENT 15 error errno 34 16 verbose exit [ 34, true ] 

I can not find a solution to this problem anywhere. The PATH variable is configured correctly, as node and npm work.

+7
powershell npm
source share
2 answers

Use .npmrc to set the prefix explicitly:

  • Go to \Users\%USERNAME%\.npmrc . For example, in Powershell:

     Notepad "\Users\$env:USERNAME\.npmrc" 
  • Set the prefix:

     prefix = "C:/Program Files/nodejs" 

References

+4
source share

It was a lot easier for me to do this in Powershell.

 $env:Path += ";C:\Program Files\nodejs\" 

Ran "npm" in powershell, and immediately came up with.

+4
source share

All Articles