npm安装不在GitHub上安装最新版本

use*_*106 37 node.js npm express sails.js waterline

我有一个名为'sails-mongo'的模块,我想使用以下命令将其更新到最新版本:

npm update sails-mongo --save
Run Code Online (Sandbox Code Playgroud)

我也试过卸载然后重新安装.我试着sails-mongo@latestsails-mongo@beta.

问题:GitHub上的当前版本(master)package.json(https://github.com/balderdashy/sails-mongo/blob/master/package.json)文件具有:

"dependencies": {
  "async": "~0.2.9",
  "lodash": "~2.4.1",
  "mongodb": "1.4.2",
  "waterline-errors": "~0.10.0"
},
Run Code Online (Sandbox Code Playgroud)

并在一个正在更新

"dependencies": {
  "async": "0.2.10",
  "underscore": "1.5.2",
  "underscore.string": "2.3.3",
  "mongodb": "~1.3.23"
},
Run Code Online (Sandbox Code Playgroud)

获得master分支的唯一方法是使用该命令 npm install git+https://github.com/balderdashy/sails-mongo

为什么不sails-mongo@latest安装master分支?

aps*_*ers 44

默认情况下,NPM依赖项从NPM存储库中提取.作者必须手动将其软件的新版本上载到NPM存储库,因此@latestNPM上托管的代码版本不同于任何地方存在的最新版代码(例如,在GitHub上).

据故宫库的上帆信息页面,最新的NPM-托管版本0.9.16,而当前的GitHub的版本0.10.0-rc3.

如果你想让你的项目依赖于特定的分支或特定Git仓库的提交(而不是NPM仓库上托管的版本),NPM开发人员已经包含了一个明确的机制来允许这个,详见" Git" package.json文档中的 " 作为依赖关系的URL " :

Git URL作为依赖项

Git网址可以是以下形式:

git://github.com/user/project.git#commit-ish
git+ssh://user@hostname:project.git#commit-ish
git+ssh://user@hostname/project.git#commit-ish
git+http://user@hostname/project/blah.git#commit-ish
git+https://user@hostname/project/blah.git#commit-ish
Run Code Online (Sandbox Code Playgroud)

commit-ish可以是任何标签,沙,或分支可以作为参数被供给git checkout.默认是master.

事实上,使用Github.com repo作为依赖项更容易:

从版本1.1.65开始,您可以将GitHub URL称为just "foo": "user/foo-project".例如:

{
  "name": "foo",
  "version": "0.0.0",
  "dependencies": {
    "express": "visionmedia/express"
  }
}
Run Code Online (Sandbox Code Playgroud)

因此,要使用Sails GitHub仓库,只需使用:

"dependencies": {
  "sails": "balderdashy/sails-mongo",
  ...
}
Run Code Online (Sandbox Code Playgroud)

并且要使用自2014年4月28日起在GitHub上存在的Sails的确切状态,请使用:

"dependencies": {
  "sails": "git://github.com/balderdashy/sails-mongo#b9cdce9a48",
  ...
}
Run Code Online (Sandbox Code Playgroud)