Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install doesn't work in Windows PowerShell

So my problem is this. I have a project with a package.json. When I in the command prompt (cmd.exe) run "npm install" everything installs as expected. However when I do the exact same thing in PowerShell (powershell.exe) I get an error: "npm ERR! Error: ENOENT, open 'c:\package.json'" even though I ran "npm install" in the path of the project. It always searches for package.json in c: for some reason I can't understand.

Below is the npm-debug.log (which also is written i c: even though 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 [email protected]
3 info using [email protected]
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     <[email protected]>
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't find a solution to this problem anywhere. The PATH variable is setup correctly since both node and npm itself works.

like image 567
dotnetdummy Avatar asked Oct 24 '13 15:10

dotnetdummy


People also ask

Why npm install is not working?

The Npm command not found error can appear when you install or upgrade npm. On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.

Why npm is not working in CMD?

You need to make sure you have a package. json file right in the current directory where you run the command. Once you see there's a package. json file in the output as shown above, then you can run the npm install command.


1 Answers

For me, it was much easier to do this in Powershell.

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

Ran "npm" in powershell, and came up straight away.

like image 82
HelpfulStranger Avatar answered Sep 19 '22 23:09

HelpfulStranger