Do I need to publish to npm every time I update a package available via git?

匿名 (未验证) 提交于 2019-12-03 01:55:01

问题:

Say I maintain an incredible crab-season package. I've npm published version 0.1.0 with a package.json containing:

"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?

回答1:

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:

deploy:    provider: npm   api_key: "YOUR API KEY"   on:     - tags: true 

Check the travis docs for details. There's also a step-by-step guide in this post.



回答2:

After publishing a few modules, the answer is yes, you need to npm publish to get new versions on 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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!