每次我通过 git 更新可用的包时,我都需要发布到 npm 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13507763/
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
Do I need to publish to npm every time I update a package available via git?
提问by hurrymaplelad
Say I maintain an incredible crab-season
package. I've npm publish
ed version 0.1.0 with a package.json
containing:
假设我维护了一个令人难以置信的crab-season
包。我已经npm publish
编辑了 0.1.0 版,其中package.json
包含:
"repository": {
"type": "git",
"url": "https://github.com/example/crab-season.git"
}
When I add awesome new features, bump the version to 0.2.0, and push to github will the npmjs registry notice my new version or do I need to npm publish
each time?
当我添加很棒的新功能,将版本提升到 0.2.0,然后推送到 github 时,npmjs 注册表会注意到我的新版本还是npm publish
每次都需要?
采纳答案by hurrymaplelad
After publishing a few modules, the answer is yes, you need to npm publish
to get new versions on npmjs.
发布了几个模块后,答案是肯定的,你需要npm publish
在 npmjs 上获取新版本。
This gives the module author the flexibility to bump their version number as soon as they start work on the next version, or any time before the version is finished.
这使模块作者可以在下一个版本开始工作时或在版本完成之前的任何时间灵活地增加他们的版本号。
npm version
handily speeds up this flow by detecting a git repository, bumping the version in package.json
, committing the change, and tagging the change with the version number.
npm version
通过检测 git 存储库、插入版本package.json
、提交更改并使用版本号标记更改,可以轻松加快此流程。
回答by hurrymaplelad
Travis CI can publish to npm when you push a version tag to reduce the overhead of releasing a change. Enable in your .travis.yml
with:
Travis CI 可以在推送版本标签时发布到 npm 以减少发布更改的开销。启用您.travis.yml
的:
deploy:
provider: npm
api_key: "YOUR API KEY"
on:
- tags: true
Check the travis docsfor details. There's also a step-by-step guide in this post.