javascript npm git存储库未更新版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15367250/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 00:33:06  来源:igfitidea点击:

npm git repository not updating versions

javascriptnode.jsconfigurationnpmbuild-system

提问by José Leal

I have an git repo and I'm trying to set it as a dependency in my project. Using NPM, my package.jsonlooks like this:

我有一个 git repo,我正在尝试将它设置为我项目中的依赖项。使用 NPM,我package.json看起来像这样:

"devDependencies": {
  "grunt": "~0.4.0",
  "grunt-contrib-connect": "~0.2.0",
  "grunt-contrib-watch": "~0.3.1",
  "custom":     "git://github.com/myGitHubRepo/repo.js.git#b7d53a0cfbe496ad89bde6f22324219d098dedb3",
  "grunt-contrib-copy": "~0.4.0"
}

On the first

在第一

npm install

It install everything and fetches the repository with no problem. But if I change this commit hash to let's say

它安装所有内容并毫无问题地获取存储库。但是如果我改变这个提交哈希让我们说

"custom":     "git://github.com/myGitHubRepo/repo.js.git#d6da3a0...", // a different one

It doesn't update! Can anyone point me out how could I get this behavior?

它不更新!谁能指出我怎么会得到这种行为?

I would simply like to share this code and be able to at some point change this version and the npmwould automatically update this.

我只是想分享这个代码,并且能够在某个时候更改这个版本,并且npm会自动更新它。

回答by Michael

Ok this is how it is done.

好的,这是如何完成的。

I was also confused.

我也很困惑。

So i have a private npm module at [email protected]:myModule/MySweetModule.git I have just published the latest tagged version. Unfortunately i cannot figure out how that works, BUT it works off your master. SOOO your master branch can be your integration branch and you have stage branch for building up the next version. Upon version completion, just merge it into master and increment your private repo's version (so your private repo now went from 1.0.0 to 1.0.1). If you call npm installit will update your repo if the master's package.json version is greater than current working repo. It will always take the latest repo.

所以我在 [email protected]:myModule/MySweetModule.git 有一个私有的 npm 模块我刚刚发布了最新的标记版本。不幸的是,我无法弄清楚它是如何工作的,但它在您的主人身上起作用。SOOO 您的 master 分支可以是您的集成分支,并且您有用于构建下一个版本的 stage 分支。版本完成后,只需将其合并到 master 并增加您的私有仓库的版本(因此您的私有仓库现在从 1.0.0 到 1.0.1)。如果npm installmaster 的 package.json 版本大于当前工作 repo,则调用它会更新您的 repo。它将始终采用最新的回购。

That seems like it sucks

好像很烂

I agree. So lets do it a better way! If you tagsfor your private repo releases you can reference them by "custom": "git+ssh://[email protected]:usr/proj.git#TAG_NAME"

我同意。所以让我们做一个更好的方法!如果您tags为您的私人回购发布,您可以通过以下方式引用它们"custom": "git+ssh://[email protected]:usr/proj.git#TAG_NAME"

So it i have a tag called 0.1.0, then i would have the url in package.json versioned like so. "custom": "git+ssh://[email protected]:usr/proj.git#0.1.0"

所以我有一个名为 的标签0.1.0,然后我会将 package.json 中的 url 版本化为这样。"custom": "git+ssh://[email protected]:usr/proj.git#0.1.0"

I believe that this is the best approach to your answer. But i am not a gitanista

我相信这是回答您的最佳方法。但我不是 gitanista

WARNING

警告

If you try to go back a version, it appears it does not work. so from version 0.2.2to 0.2.1it will not update your project. Make sure you do npm remove myProjthen npm installif you roll back a version.

如果您尝试返回某个版本,它似乎不起作用。所以从版本0.2.20.2.1它不会更新你的项目。请确保你做npm remove myProj那么npm install,如果你回滚的版本。

回答by Leo Gallucci

This have been fixedin npm, please upgrade to npm >= 1.3.10

这已经在 npm 中修复了,请升级到 npm >= 1.3.10

Sample usage

示例用法

"dependencies": { "thing": "git://github.com/myGitHubRepo/repo.js.git#56477cb", }

"dependencies": { "thing": "git://github.com/myGitHubRepo/repo.js.git#56477cb", }

Some day later

一天后

"dependencies": { "thing": "git://github.com/myGitHubRepo/repo.js.git#67f90b5", }

"dependencies": { "thing": "git://github.com/myGitHubRepo/repo.js.git#67f90b5", }

Then npm installagain and you will get new ref!

然后npm install再次,你会得到新的参考!

If your "myGitHubRepo/repo.js" is a privatepackage you should set "private": truethere to ensure it doesn't get accidentally published to npm registry

如果你的“myGitHubRepo/repo.js”是一个私有包,你应该在"private": true那里设置以确保它不会被意外发布到 npm 注册表