I have a module called 'sails-mongo' and I want to update it to the newest version using the following command:
我有一个名为sails-mongo的模块,我想使用以下命令将它更新为最新版本:
npm update sails-mongo --save
I also tried uninstall then install again. I tried sails-mongo@latest
and sails-mongo@beta
.
我也尝试卸载然后再安装。我尝试了sails-mongo@latest和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:
问题:GitHub上的当前版本(master)。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"
},
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
我获得主分支的唯一方法是使用命令npm安装git+https://github.com/balderdashy/sails-mongo。
Why doesn't sails-mongo@latest
install the master branch?
为什么sails-mongo@latest不安装主分支?
2 个解决方案
#1
42
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).
默认情况下,NPM依赖项是从NPM存储库中提取的。作者必须手动将软件的新版本上载到NPM存储库,因此NPM上托管的代码的“@latest”版本与任何地方都存在的最新版本(例如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
.
根据NPM储存库关于sail的信息页面,最新的NPM托管版本是0.9.16,而当前的GitHub版本是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 repo的提交(而不是托管在NPM存储库上的版本),那么NPM开发人员已经包含了一个显式的机制来允许这一点,在包的“Git url作为依赖项”中详细介绍。json文档:
Git URLs as Dependencies
Git url作为依赖项
Git urls can be of the form:
Git url可以是:
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 togit checkout
. The default ismaster
.提交可以是任何标记、sha或分支,可以作为git签出的参数提供。默认是主人。
In fact, it's easier still to use a Github.com repo as a dependency:
事实上,使用Github.com的repo作为依赖项更容易:
As of version 1.1.65, you can refer to GitHub urls as just
"foo": "user/foo-project"
. For example:在1.1.65版本中,您可以将GitHub url称为“foo”:“user/foo-project”。例如:
{ "name": "foo", "version": "0.0.0", "dependencies": { "express": "visionmedia/express" } }
So, to use the Sails GitHub repo, simply use:
因此,要使用船帆GitHub repo,只需使用:
"dependencies": {
"sails": "balderdashy/sails-mongo",
...
}
And to use the exact state of Sails as it exists on GitHub as of April 28, 2014, use:
使用GitHub上截至2014年4月28日的船帆的确切状态,请使用:
"dependencies": {
"sails": "git://github.com/balderdashy/sails-mongo#b9cdce9a48",
...
}
#2
1
I had a similar issue. Via the NPM Registry I was trying to get the latest from a project I saw in in GitHub, like this:
我也有类似的问题。通过NPM注册表,我试图从我在GitHub上看到的一个项目中获得最新的信息,比如:
//package.json
"devDependencies": {
"foo-package": "^3.3.0",
}
But the code I got back from npm install
(as observed in the node_modules/
folder) was not what I saw in GitHub repository's master branch. I was confused; as the two didn't match.
但是我从npm安装中得到的代码(如node_modules/文件夹中所见)并不是我在GitHub存储库的主分支中看到的。我很困惑;因为这两个不匹配。
I eventually found: https://docs.npmjs.com/cli/view, which reveals some information (versions and dates) of what the NPM Registry is aware of for a particular repository.
我最终找到了:https://docs.npmjs.com/cli/view,它揭示了NPM注册中心对于特定存储库的一些信息(版本和日期)。
// Console example
npm view foo-package
After confirming that what I wanted from GitHub repository's master branch wasn't in the NPM Registry, I eventually changed my approach Git URLs as Dependencies, just as @apsillers answers.
在确认了我想从GitHub存储库的主分支中得到的东西不在NPM注册中心之后,我最终将我的方法Git url更改为依赖项,就像@apsillers回答的那样。
#1
42
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).
默认情况下,NPM依赖项是从NPM存储库中提取的。作者必须手动将软件的新版本上载到NPM存储库,因此NPM上托管的代码的“@latest”版本与任何地方都存在的最新版本(例如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
.
根据NPM储存库关于sail的信息页面,最新的NPM托管版本是0.9.16,而当前的GitHub版本是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 repo的提交(而不是托管在NPM存储库上的版本),那么NPM开发人员已经包含了一个显式的机制来允许这一点,在包的“Git url作为依赖项”中详细介绍。json文档:
Git URLs as Dependencies
Git url作为依赖项
Git urls can be of the form:
Git url可以是:
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 togit checkout
. The default ismaster
.提交可以是任何标记、sha或分支,可以作为git签出的参数提供。默认是主人。
In fact, it's easier still to use a Github.com repo as a dependency:
事实上,使用Github.com的repo作为依赖项更容易:
As of version 1.1.65, you can refer to GitHub urls as just
"foo": "user/foo-project"
. For example:在1.1.65版本中,您可以将GitHub url称为“foo”:“user/foo-project”。例如:
{ "name": "foo", "version": "0.0.0", "dependencies": { "express": "visionmedia/express" } }
So, to use the Sails GitHub repo, simply use:
因此,要使用船帆GitHub repo,只需使用:
"dependencies": {
"sails": "balderdashy/sails-mongo",
...
}
And to use the exact state of Sails as it exists on GitHub as of April 28, 2014, use:
使用GitHub上截至2014年4月28日的船帆的确切状态,请使用:
"dependencies": {
"sails": "git://github.com/balderdashy/sails-mongo#b9cdce9a48",
...
}
#2
1
I had a similar issue. Via the NPM Registry I was trying to get the latest from a project I saw in in GitHub, like this:
我也有类似的问题。通过NPM注册表,我试图从我在GitHub上看到的一个项目中获得最新的信息,比如:
//package.json
"devDependencies": {
"foo-package": "^3.3.0",
}
But the code I got back from npm install
(as observed in the node_modules/
folder) was not what I saw in GitHub repository's master branch. I was confused; as the two didn't match.
但是我从npm安装中得到的代码(如node_modules/文件夹中所见)并不是我在GitHub存储库的主分支中看到的。我很困惑;因为这两个不匹配。
I eventually found: https://docs.npmjs.com/cli/view, which reveals some information (versions and dates) of what the NPM Registry is aware of for a particular repository.
我最终找到了:https://docs.npmjs.com/cli/view,它揭示了NPM注册中心对于特定存储库的一些信息(版本和日期)。
// Console example
npm view foo-package
After confirming that what I wanted from GitHub repository's master branch wasn't in the NPM Registry, I eventually changed my approach Git URLs as Dependencies, just as @apsillers answers.
在确认了我想从GitHub存储库的主分支中得到的东西不在NPM注册中心之后,我最终将我的方法Git url更改为依赖项,就像@apsillers回答的那样。