本文翻译自:Depend on a branch or tag using a git URL in a package.json?

Say I've forked a node module with a bugfix and I want to use my fixed version, on a feature branch of course, until the bugfix is merged and released. 假设我已经使用错误修复分叉了一个节点模块,我想在功能分支上使用我的固定版本,直到错误修复被合并和发布。

How would I reference my fixed version in the dependencies of my package.json ? 我如何在package.jsondependencies中引用我的固定版本?


#1楼

参考:https://stackoom.com/question/16bYX/在package-json中使用git-URL依赖分支或标记


#2楼

From the npm docs : 来自npm文档 :

git://github.com/<user>/<project>.git#<branch>git://github.com/<user>/<project>.git#feature\/<branch>

As of NPM version 1.1.65, you can do this: 从NPM版本1.1.65开始,您可以这样做:

<user>/<project>#<branch>

#3楼

per @dantheta's comment: 根据@ dantheta的评论:

As of npm 1.1.65, Github URL can be more concise user/project. 从npm 1.1.65开始,Github URL可以更简洁的用户/项目。 npmjs.org/doc/files/package.json.html You can attach the branch like user/project#branch npmjs.org/doc/files/package.json.html您可以附加分支,如user / project#branch

So 所以

"babel-eslint": "babel/babel-eslint",

Or for tag v1.12.0 on jscs: 或者对于jscs上的标签v1.12.0:

"jscs": "jscs-dev/node-jscs#v1.12.0",

Note, if you use npm --save, you'll get the longer git 注意,如果你使用npm --save,你会得到更长的git

From https://docs.npmjs.com/files/package.json#git-urls-as-dependencies 来自https://docs.npmjs.com/files/package.json#git-urls-as-dependencies

Git URLs as Dependencies Git URL作为依赖项

Git urls can be of the form: 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 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. commit-ish可以是任何标记,sha或分支,可以作为git checkout的参数提供。 The default is master. 默认值为master。

GitHub URLs GitHub网址

As of version 1.1.65, you can refer to GitHub urls as just "foo": "user/foo-project". 从版本1.1.65开始,您可以将GitHub URL称为“foo”:“user / foo-project”。 Just as with git URLs, a commit-ish suffix can be included. 与git URL一样,可以包含commit-ish后缀。 For example: 例如:

{ "name": "foo", {“name”:“foo”,
"version": "0.0.0", “版本”:“0.0.0”,
"dependencies": { "express": "visionmedia/express", "mocha": "visionmedia/mocha#4727d357ea" } } “依赖”:{“express”:“visionmedia / express”,“mocha”:“visionmedia / mocha#4727d357ea”}}


#4楼

If you want to use devel or feature branch, or you haven't published a certain package to the NPM registry, or you can't because it's a private module, then you can point to a git:// URI instead of a version number in your package.json : 如果你想使用develfeature分支,或者你没有将某个包发布到NPM注册表,或者你不能因为它是私有模块,那么你可以指向一个git:// URI而不是一个版本package.json

"dependencies": {"public": "git://github.com/user/repo.git#ref","private": "git+ssh://git@github.com:user/repo.git#ref"
}

The #ref portion is optional, and it can be a branch (like master ), tag (like 0.0.1 ) or a partial or full commit id. #ref部分是可选的,它可以是分支(如master ),标记(如0.0.1 )或部分或完整的提交ID。


#5楼

On latest version of NPM you can just do: 在最新版本的NPM上你可以做到:

npm install gitAuthor/gitRepo#tag

If the repo is a valid NPM package it will be auto-aliased in package.json as: 如果repo是一个有效的NPM包,它将在package.json中自动别名为:

{ "NPMPackageName": "gitAuthor/gitRepo#tag" }

If you could add this to @justingordon 's answer there is no need for manual aliasing now ! 如果您可以将此添加到@justingordon的答案,那么现在就不需要手动别名了!

在package.json中使用git URL依赖分支或标记?相关推荐

  1. npm,ncu 一键升级 package.json 中依赖的版本

    一.场景:运行老项目,使用的新语法,发现报错各种不兼容提示,一个一个升级依赖又太麻烦,so网上找到了这个插件 ncm 一.安装 npm install -g npm-check-updates 二.检 ...

  2. android中json插件,【Android原生插件】package.json中关于第三方aar的配置

    按照文档(https://ask.dcloud.net.cn/article/35414)所说: dependencies节点特殊说明 android插件中集成的第三方SDK 如果是jar或so放入到 ...

  3. package.json 中的波浪号(~)和插入符号(^)有什么区别?

    问题描述: 在我升级到最新的稳定版 node 和 npm 后,我尝试了 npm install moment --save.它使用插入符号 ^ 前缀将条目保存在 package.json 中.以前,它 ...

  4. 前端package.json中的scripts

    前言 一直很好奇package.json里的scripts属性,查了一下文章,问了一下公司里的前辈.大体上理解了,因此写这篇文章来记录一下. 本文默认你前端项目已经安装并配置了相关依赖.添加链接描述 ...

  5. npm 模块 移除_【已解决】npm卸载模块后该模块并没有从package.json中去掉

    折腾: 期间,遇到一个奇怪的现象: 用npm remove xxx或npm uninstall xxx后 xxx并没有从package.json中去掉:➜  HeadquarterReport git ...

  6. package.json 中的 Module 字段是干嘛的

    引入 最近团队的一个同学在搞 npm library 源码的调试插件,因为内部的一个组件库含有大量的逻辑,在某个项目中不经意就出现一个磨人的 bug,但是组件库发布都是打包编译后的代码,而且没有 pu ...

  7. npm install安装固定版本号以及package.json中版本号详解

    在npm中安装固定的版本号package,只需要在其后加 '@版本号' npm install three@0.102.1 Node.js中package.json中库的版本号详解: 1. ~ 匹配最 ...

  8. npm更新模块并同步到package.json中

    使用原始npm 1.查看需要更新的版本 npm outdated 该命令会列出所有需要更新的项目 2.修改package.json中需要更新的包对应的版本号 npm update 由于npm upda ...

  9. Node.js中package.json中库的版本号详解(^和~区别)

    Node.js中package.json中库的版本号详解(^和~区别) 当我们查看package.json中已安装的库的时候,会发现他们的版本号之前都会加一个符号,有的是插入符号(^),有的是波浪符号 ...

最新文章

  1. vue :class 动态绑定样式_Notes04vbind动态绑定class
  2. 工业机器人入门实用教程_机器学习实用入门
  3. webpack二(以webpack4.x起步)
  4. Jenkins 与 Kubernetes 的 CI 与 CD Git + Maven + Docker+Kubectl
  5. linux下dnw工具安装和使用
  6. 转帖:免费申请样片的公司大全!!
  7. IOS经常使用的性能优化策略
  8. 2.深入分布式缓存:从原理到实践 --- 分布式系统理论
  9. AD OU管理|委派密码重置权限
  10. 前端项目构建工具---Grunt
  11. 语音排队叫号系统源码
  12. 三星note9刷Android9,三星Note9官方韩版安卓9固件rom线刷刷机包:N960NKSU2CSE3
  13. zmap扫描mysql_ZMap扫描机制剖析
  14. 数字信号处理知识点总结(三):离散傅里叶变换(DFT)
  15. 5分钟教你制作独一无二的卡通头像,新手做自媒体,不敢真人露脸
  16. Java8 Collectors.joining() 详解
  17. CSA标准|《物联网安全规范》(征求意见稿)意见征集
  18. Java网络商城项目 SpringBoot+SpringCloud+Vue 网络商城(SSM前后端分离项目)十六(商品排序,Thymeleaf快速入门,商品详情页的展示)
  19. java j2c_将Java源代码转换为C++源代码的工具
  20. 不会水的人,如何自学游泳

热门文章

  1. 如何在WebGL全景图上做标记
  2. 【POJ】2823 Sliding Window
  3. MySQL数据库的常用命令语句记录——安全用户语句及函数
  4. annotatedClasses和component-scan冲突吗
  5. java OOP及相关基础知识汇总(转)
  6. BinaryWrite方法输出验证码
  7. 百度缺的不是狼性,而是鲁滨逊
  8. 6-19 day17 内置函数 16:52-17:43
  9. SyntaxError: Missing parentheses in call to 'print' 这个错误原因是Python版本问题
  10. 【紫书】(UVa12096) The SetStack Computer