-1

I got the annoying error when try to put dependencies via npm on windows. I gave correct name to package.json. Help me !

D:\sitenode>npm install
npm ERR! install Couldn't read dependencies
npm ERR! Error: Invalid version: "0.1"
npm ERR!     at Object.module.exports.fixVersionField (C:\Program Files\nodejs\n
ode_modules\npm\node_modules\read-package-json\node_modules\normalize-package-da
ta\lib\fixer.js:183:13)
  • 1
    possible duplicate of [npm: Why is a version "0.1" invalid?](http://stackoverflow.com/questions/16887993/npm-why-is-a-version-0-1-invalid) – Qantas 94 Heavy Sep 03 '14 at 10:44
  • that is not duplicate ! I found it and I tried it but I didn't correct output. So – Nyi Nyi Naing Sep 03 '14 at 10:47
  • Could you explain where you tried to fix it? – Qantas 94 Heavy Sep 03 '14 at 10:49
  • copied another json file form online repo and replace with my json codes. And i tried to install again. but i got the same error. But when i install jsom file form online repo, it worked properly. – Nyi Nyi Naing Sep 03 '14 at 10:52
  • could you show your packages.json file ?? I think there's something wrong in json – Naing Lin Aung Sep 03 '14 at 11:09
  • '{ "name" : "SiteWithNode", "version" : "v0.1", "private" : "true", "dependencies" : { "express" : "3.0.0alpha4", "jade" : "*", "stylus" : "*", "nib" : "*" } }' – Nyi Nyi Naing Sep 03 '14 at 11:14
  • 1
    Your version string is not compliant with [semantic versioning](http://semver.org/). – Qantas 94 Heavy Sep 03 '14 at 11:19
  • I fix according [link](https://stackoverflow.com/questions/16887993/npm-why-is-a-version-0-1-invalid) that link but it show same errors !! – Nyi Nyi Naing Sep 03 '14 at 11:24
  • `install` `Couldn't read dependencies` `npm ERR! Error: Invalid name: "React Learning"` so by reading here I found in my case name `React Learning` is not correct. I removed white space it works. – Ramratan Gupta Apr 12 '16 at 00:56

1 Answers1

6

You need to fix your string with semantic versioning. every version must be come with ..* style (three digits). so I changed your package.json and it's work

{ "name" : "SiteWithNode", 
  "version" : "0.0.1", 
  "private" : "true", 
  "dependencies" : { 
    "express" : "*.*.*", 
    "jade" : "*.*.*", 
    "stylus" : "*.*.*", 
    "nib" : "*.*.*" 
  } 
}

of course you might want to config (setup to fix certain versions due to compatibility). You might want to take a look at here

Naing Lin Aung
  • 3,373
  • 4
  • 31
  • 48