npm安装不在GitHub上安装最新版本 [英] npm install not installing latest version on GitHub

查看:303
本文介绍了npm安装不在GitHub上安装最新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  npm update sails-mongo --save 

我还尝试卸载然后重新安装。我试过 sails-mongo @ latest sails-mongo @ beta



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

 依赖:{
async:〜0.2.9,
lodash:〜2.4 .1,
mongodb:1.4.2,
waterline-errors:〜0.10.0
},

在正在更新的

 依赖关系:{
async:0.2.10,
underscore:1.5.2,
underscore.string:2.3.3,
mongodb:〜1.3.23
},

唯一的方法我得到主分支正在使用命令 npm install git + https://github.com/balderdashy/sails-mongo



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

解决方案

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



根据NPM资源库的信息Sails上的页面,最新的NPM托管版本为 0.9.16 ,而当前的GitHub版本 0.10.0-rc3



如果您希望让项目依赖特定的分支或提交特定的Git repo(而不是NPM存储库上托管的版本),则NPM开发人员已经包括一个明确的机制来允许这个详细的在 Git URL as Dependencies中的


Git网址作为依赖关系



Git网址可以是以下形式:

 code> 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

commit-ish 可以是可以作为 git checkout 的参数提供的任何标签,sha或分支。默认值为 master


事实上, href =https://www.npmjs.org/doc/json.html#GitHub-URLs>使用Github.com repo 作为依赖关系:


从版本1.1.65起,您可以将GitHub url引用为foo:user / foo-project。例如:

  {
name:foo,
version:0.0 .0,
依赖:{
express:visionmedia / express
}
}


所以,要使用Sails GitHub repo,只需使用:

 依赖:{
sails:balderdashy / sails-mongo,
...
}

要使用截至2014年4月28日GitHub上确切的Sails状态,请使用:

 依赖关系:{
sails:git://github.com/balderdashy/sails-mongo#b9cdce9a48,
...
}


I have a module called 'sails-mongo' and I want to update it to the newest version using the following command:

npm update sails-mongo --save

I also tried uninstall then install again. I tried sails-mongo@latest and sails-mongo@beta.

Problem: The current version (master) on GitHub the package.json (https://github.com/balderdashy/sails-mongo/blob/master/package.json) file has:

"dependencies": {
  "async": "~0.2.9",
  "lodash": "~2.4.1",
  "mongodb": "1.4.2",
  "waterline-errors": "~0.10.0"
},

And in the one being updated

"dependencies": {
  "async": "0.2.10",
  "underscore": "1.5.2",
  "underscore.string": "2.3.3",
  "mongodb": "~1.3.23"
},

The only way I get the master branch is using the command npm install git+https://github.com/balderdashy/sails-mongo

Why doesn't sails-mongo@latest install the master branch?

解决方案

By default, NPM dependencies are pulled from the NPM repository. Authors must manually upload new versions of their software to the NPM repository, so the "@latest" version of the code hosted on NPM is different from the latest version of the code that exists anywhere (e.g., on GitHub).

According to the NPM repository's info page on Sails, the latest NPM-hosted version is 0.9.16 while the current GitHub version is 0.10.0-rc3.

If you want to have your project depend upon a particular branch or commit of a particular Git repo (instead of the version(s) hosted on the NPM repository), the NPM developers have included an explicit mechanism to allow this, detailed in "Git URLs as Dependencies" in the package.json docs:

Git URLs as Dependencies

Git urls can be of the form:

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

The commit-ish can be any tag, sha, or branch which can be supplied as an argument to git checkout. The default is master.

In fact, it's easier still to use a Github.com repo as a dependency:

As of version 1.1.65, you can refer to GitHub urls as just "foo": "user/foo-project". For example:

{
  "name": "foo",
  "version": "0.0.0",
  "dependencies": {
    "express": "visionmedia/express"
  }
}

So, to use the Sails GitHub repo, simply use:

"dependencies": {
  "sails": "balderdashy/sails-mongo",
  ...
}

And to use the exact state of Sails as it exists on GitHub as of April 28, 2014, use:

"dependencies": {
  "sails": "git://github.com/balderdashy/sails-mongo#b9cdce9a48",
  ...
}

这篇关于npm安装不在GitHub上安装最新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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