52

I wanted to start a Node app and created a package.json file with a tutorial. Here is the json file:

{
    "name": "Dashboard",
    "version": "0.0.0",
    "description": "Client-A Dashboard",
    "dependencies": {
        "socket.io": "latest",
        "express": "latest",
        "jade": "latest"
    },
    "author": "tD"
}

I verified JSON file before trying to run it, but still I got an error message when I ran the npm install command:

npm ERR! install Couldn't read dependencies
npm ERR! Error: ENOENT, open 'C:\projects\Client-A\Live\package.json'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\projects\Client-A\Live\
npm ERR! node -v v0.8.22
npm ERR! npm -v 1.2.14
npm ERR! path C:\projects\Client-A\Live\package.json
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\projects\Client-A\Live\npm-debug.log
npm ERR! not ok code 0

and here is the npm-degub.log file

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files (x86)\\nodejs\\\\node.exe',
1 verbose cli   'C:\\Program Files (x86)\\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 (x86)\nodejs\\node.exe
5 verbose read json C:\projects\Client-A\Live\package.json
6 error install Couldn't read dependencies
7 error Error: ENOENT, open 'C:\projects\Client-A\Live\package.json'
8 error If you need help, you may report this log at:
8 error     <http://github.com/isaacs/npm/issues>
8 error or email it to:
8 error     <[email protected]>
9 error System Windows_NT 6.1.7601
10 error command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
11 error cwd C:\projects\Client-A\Live\scoreboard
12 error node -v v0.8.22
13 error npm -v 1.2.14
14 error path C:\projects\Client-A\Live\package.json
15 error code ENOENT
16 error errno 34
17 verbose exit [ 34, true ]
4
  • 25
    Can you confirm you are running npm install from the same directory as the package.json file?
    – badsyntax
    Commented Aug 23, 2013 at 11:45
  • Yes, I was in same directory Commented Aug 23, 2013 at 11:56
  • Open the CMD with run as administrator and try to install.
    – Chandu
    Commented Aug 23, 2013 at 12:15
  • I received permission error when I tried without "run as admin". I got the error above with admin privileges. Commented Aug 23, 2013 at 14:54

17 Answers 17

58

I had an "Invalid Name"

I switched from "name": "Some Name",... to "name": "Some-Name",...

Guess name needs to be a sluggy string.

3
  • 1
    Is this documented any where?
    – srijan
    Commented Mar 20, 2014 at 21:31
  • Doesn't seem so. I never reported it either :/
    – Cody
    Commented Mar 24, 2014 at 7:21
  • This was it for me too.
    – sheppe
    Commented May 17, 2016 at 18:38
29

Try to add this:

"private": true,

it worked for me.

EDIT (for people asking why):

The Oficial documentation states the following:


If you set "private": true in your package.json, then npm will refuse to publish it. This is a way to prevent accidental publication of private repositories. If you would like to ensure that a given package is only ever published to a specific registry (for example, an internal registry), then use the publishConfig hash described below to override the registry config param at publish-time.


The error messages you are getting may be related to violating this "rule" in a way (mine was).

  • Either you are marking a unpublished package (like your own app) as "private": false.
  • Or you are neglecting to include any value at all.
5
  • glad it did, I hope it does help more people :) Commented Oct 3, 2013 at 14:04
  • 2
    Why does this fix it? I got a similar issue but this could not fix it. Is there something deeper here? (thank you for your answer though! - just trying to find what's going on with my build :) ) Commented Oct 3, 2013 at 14:24
  • 3
    Ahh nevermind, realized I wasn't in the right directory when running it. Thanks! Commented Oct 3, 2013 at 14:43
  • Worked for me too. but why? Commented Dec 26, 2013 at 9:53
  • 2
    "private": true, :where should i add this ?
    – Developer
    Commented Nov 21, 2014 at 5:29
26

Recently, I've started to get an error:

npm ERR! install Couldn't read dependencies
npm ERR! Error: Invalid version: "1.0"

So, you may need to specify version of your package with 3 numbers, e.g. 1.0.0 instead of 1.0 if you get similar error.

0
13

It's simple, you're just not in the right directory.

Go to the C:\Program Files\nodejs\node_modules\npm and you should be able to run this command properly.

2
  • That's one possible cause, but definitely not the only one. Commented May 9, 2014 at 2:21
  • For me this was the problem.
    – James
    Commented Feb 6, 2015 at 13:15
11

Try to update npm,It works for me

[sudo] npm install -g npm
1
  • 2
    What does this do? This worked for me but I cannot use npm install on it's own. Commented Apr 1, 2016 at 15:37
4

I got the same exception also, but it was previously running fine in another machine. Anyway above solution didn't worked for me. What i did to resolve it?

  1. Copy dependencies list into clipboard.
  2. enter "npm init" to create fresh new package.json
  3. Paste the dependencies again back to package.json
  4. run "npm install" again!

Done :) Hope it helps.

2
  • Yeah, weird, after manually creating the node_modules folder and the package.json file, it worked Commented May 26, 2015 at 20:43
  • Yeah i was struggling to run it then search over but couldn't make it work. Finally above method worked for me. Glad that helped :)
    – Hadi
    Commented May 27, 2015 at 5:34
2

For me it was the version. Yes, the line you put at the root, like :

{
    "name": "your-project",
    "version": "0.1"
    ...
}

Yes, npm doesn't like version like this, it prefers something like "0.0.1".

Don't ask me why, I'll tell you it's totally stupid (or "how to loose time easily")

2

My mistake was the I named the file packages.json instead of package.json

1

I figured out I wasn't in the correct folder. I needed goto the folder I just cloned before I ran this command.

2
  • Lol, I just did the same thing and seeing your answer made me use my brain. Thank you. :) Commented Feb 24, 2015 at 13:12
  • Glad my mistake was not in vain :) and Glad I could help Commented Feb 24, 2015 at 13:18
1

I got this error when I had a space in my "name" within the packagae.json file.

"NPM Project" rather than "NPMProject"

0

Problem with not reading the json is linked to permission issues with the file.

Using this command will do the trick:

sudo chown -R $USER:$GROUP ~/.npm

0

This doesn't look like your issue, but for the sake of others, for me this was caused by an invalid version number in package.json (had to change 2.4 to 2.4.0).

0

1)Nodejs installs in C:\ProgramFiles in some cases. Try installing in C: drive or another directory if you don't have admin rights.

2)Make sure you are not installing behind a company's proxy setting. This can sometimes affect installation.

3) Finally, make sure you run the npm command from this directory: Path\nodejs\node_modules\npm where Path is your own directory.

0

I resolved that problem just moving my project from E: to C:. I think it happened becouse nodejs and npm was installed in my C: and the project was in my E:

0

I ran into this problem after I cloned a git repository to a directory, renamed the directory, then tried to run npm install. I'm not sure what the problem was, but something was bungled. Deleting everything, re-cloning (this time with the correct directory name), and then running npm install resolved my issue.

0

Verify user account, you are working on. If any system user has no permissions for installation packages, npm particulary also is showing this message.

-2

I was following a doc on line and thought this error meant a problem with the dependencies in NPM. however after a third look. I realized that it was a typo. I did not add a comma after the first dependency in package.json that the tutorial asked me to edit.

Not the answer you're looking for? Browse other questions tagged or ask your own question.