node.js - 在 package.json 中使用 git 标签(用于 git 依赖项)

标签 node.js git github npm

是否有可能像 npm 包一样获取 git 依赖项的更新行为?

所以我有 git 依赖:

"dependencies": {
"my-module": "github:me/my-module"
}

并希望每次执行 npm install 时都更新它,添加修订散列是解决方案,但每次在 github 上更新包时都需要做更多工作来跟踪和更新 package.json。

还有 git 标签(也可以使用 npm version.. 命令设置 - 它创建了带有标签 v1.2.3 的提交。所以我想也许他们是如何在 dependents package.json 中使用这个标签?

希望我说清楚了。

repo 上的 git 标签给了我

v1.0.1 v1.0.0 ..

如果我尝试在模块名称版本之后添加 package.json,例如:#1.0.0 或 #v1.0.1

```
"dependencies": {
"my-module": "github:me/my-module#1.0.1"
}
```

安装失败并出现错误:

Command failed: git -c core.longpaths=true rev-list -n1 1.0.0
fatal: ambiguous argument '1.0.0': unknown revision or path not in the
ree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'


If you need help, you may report this error at:
    <https://github.com/npm/npm/issues>

...

最佳答案

可以这样做

"我的模块": "git+https://github.com/user/repo.git#v1.2.3"

关于node.js - 在 package.json 中使用 git 标签(用于 git 依赖项),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35228918/

相关文章:

javascript - Electron 应用名称不变

node.js - 为什么每次关闭浏览器时我的 session 都会过期?

node.js - 使用 NPM 和 grunt js 构建系统

javascript - GitHub 使用什么 JavaScript 语法高亮器?

android - 通过 react native 添加 map

node.js - 为什么我在使用 selenium chromedriver 时会出现此错误?

GitHub markdown 不渲染,git 在没有更改时检测更改

git - 我如何在本地使用 git 命名空间?

regex - 忽略与 git diff 中的字符串匹配的更改

git - 如何在谷歌计算引擎中安装 git?