Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm: Why is a version "0.1" invalid?

Tags:

node.js

npm

I had to change the version of my npm app from 0.1 to 0.0.1 in order for npm not to do this.

$ npm install npm ERR! install Couldn't read dependencies npm ERR! Error: invalid version: 0.1 npm ERR!     at validVersion (/usr/local/Cellar/node/0.10.5/lib/node_modules/npm/node_modul es/read-package-json/read-json.js:571:40) npm ERR!     at final (/usr/local/Cellar/node/0.10.5/lib/node_modules/npm/node_modules/read -package-json/read-json.js:323:23) npm ERR!     at /usr/local/Cellar/node/0.10.5/lib/node_modules/npm/node_modules/read-packag e-json/read-json.js:139:33 npm ERR!     at cb (/usr/local/Cellar/node/0.10.5/lib/node_modules/npm/node_modules/slide/l ib/async-map.js:48:11) npm ERR!     at /usr/local/Cellar/node/0.10.5/lib/node_modules/npm/node_modules/read-packag e-json/read-json.js:301:48 npm ERR!     at fs.js:207:20 npm ERR!     at Object.oncomplete (fs.js:107:15) 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 Darwin 12.3.0 npm ERR! command "/usr/local/Cellar/node/0.10.5/bin/node" "/usr/local/bin/npm" "install" npm ERR! cwd /Users/lust/Documents/ply/dev-server npm ERR! node -v v0.10.5 npm ERR! npm -v 1.2.18 npm ERR! npm ERR! Additional logging details can be found in: npm ERR!     /Users/lust/Documents/ply/dev-server/npm-debug.log npm ERR! not ok code 0 

For completeness here's the working json

$ cat package.json {     "name": "ply",     "description": "ply server for local dev testing deployments",     "version": "0.0.1",     "private": true,     "dependencies": {         "express": "3.x"     } }  

version used to be "0.1" when it made the error.

Is this some sort of API/ABI compatibility versioning concept requiring 3 sets of version numbers? Why is the error message not more friendly w.r.t. this?

like image 496
Steven Lu Avatar asked Jun 02 '13 22:06

Steven Lu


People also ask

Why I Cannot npm install?

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.

What is current npm version?

7.0.0 • Public • Published 2 months ago.


2 Answers

Yes, this is required for semantic versioning, which is the versioning scheme npm packages use. Here's the snippet from npm help json:

Version must be parseable by node-semver, which is bundled with npm as a dependency. (npm install semver to use it yourself.)

Here's how npm's semver implementation deviates from what's on semver.org:

  • Versions can start with "v"
  • A numeric item separated from the main three-number version by a hyphen will be interpreted as a "build" number, and will increase the version. But, if the tag is not a number separated by a hyphen, then it's treated as a pre-release tag, and is less than the version without a tag. So, 0.1.2-7 > 0.1.2-7-beta > 0.1.2-6 > 0.1.2 > 0.1.2beta
like image 64
Michelle Tilley Avatar answered Oct 06 '22 02:10

Michelle Tilley


Simple answer - use 0.1.0

0.1 will not work

Happy coding!

like image 37
Stanislau Baranouski Avatar answered Oct 06 '22 00:10

Stanislau Baranouski