Do I need to publish to npm every time I update a

2019-01-16 18:27发布

问题:

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.



标签: git publish npm