npm:为什么版本是“0.1"?无效的? [英] npm: Why is a version "0.1" invalid?

查看:54
本文介绍了npm:为什么版本是“0.1"?无效的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不将我的 npm 应用程序的版本从 0.1 更改为 0.0.1,以便 npm 不这样做.

$ npm installnpm 错误!安装无法读取依赖项npm 错误!错误:无效版本:0.1npm 错误!在有效版本 (/usr/local/Cellar/node/0.10.5/lib/node_modules/npm/node_modules/read-package-json/read-json.js:571:40)npm 错误!最后(/usr/local/Cellar/node/0.10.5/lib/node_modules/npm/node_modules/read-package-json/read-json.js:323:23)npm 错误!在/usr/local/Cellar/node/0.10.5/lib/node_modules/npm/node_modules/read-packag电子 json/read-json.js:139:33npm 错误!在 cb (/usr/local/Cellar/node/0.10.5/lib/node_modules/npm/node_modules/slide/lib/async-map.js:48:11)npm 错误!在/usr/local/Cellar/node/0.10.5/lib/node_modules/npm/node_modules/read-packag电子 json/read-json.js:301:48npm 错误!在 fs.js:207:20npm 错误!在 Object.oncomplete (fs.js:107:15)npm 错误!如果您需要帮助,可以在以下位置报告此日志:npm 错误!<http://github.com/isaacs/npm/issues>npm 错误!或电邮至:npm 错误!<npm-@googlegroups.com>npm 错误!系统达尔文 12.3.0npm 错误!命令/usr/local/Cellar/node/0.10.5/bin/node"/usr/local/bin/npm"安装"npm 错误!cwd/Users/lust/Documents/ply/dev-servernpm 错误!节点 -v v0.10.5npm 错误!npm -v 1.2.18npm 错误!npm 错误!可以在以下位置找到其他日志记录详细信息:npm 错误!/Users/lust/Documents/ply/dev-server/npm-debug.lognpm 错误!不行 代码 0

为了完整起见,这里是工作的 json

$ cat package.json{"name": "层",描述":用于本地开发测试部署的ply服务器",版本":0.0.1",私人":真的,依赖关系":{快递":3.x"}}

出现错误时的版本曾经是0.1".

这是某种需要 3 组版本号的 API/ABI 兼容性版本控制概念吗?为什么错误信息不是更友好 w.r.t.这是?

解决方案

是的,这是语义版本控制所必需的,这是 npm 包使用的版本控制方案.这是来自npm help json的片段:><块引用>

版本必须可由 node-semver 解析,它作为依赖项与 npm 捆绑在一起.(npm install semver 自己使用.)

以下是 npm 的 semver 实现与 semver.org 上的不同之处:

  • 版本可以以v"开头
  • 用连字符与主要的三数字版本分开的数字项目将被解释为构建"版本.数量,并将增加版本.但是,如果标签不是由连字符分隔的数字,则它被视为预发布标签,并且小于没有标签的版本.所以,0.1.2-7 >0.1.2-7-β>0.1.2-6 >0.1.2 >0.1.2测试版

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!     <npm-@googlegroups.com>

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?

解决方案

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

这篇关于npm:为什么版本是“0.1"?无效的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆