With npm version patch
, I can easily promote the npm package version.
Then I add below line in package.json
"publish": "npm version patch; npm publish"
When I run npm run publish
, I suppose to get the version pumped and publish automatically.
But it is not. The command goes crazy to pump and publish new version again and again.
$ npm run publish
> npm-test-package@2.0.3 publish ....
> npm version patch; npm publish
v2.0.4
> npm-test-package@2.0.4 publish .
> npm version patch; npm publish
v2.0.5
> npm-test-package@2.0.5 publish .
> npm version patch; npm publish
v2.0.6
> npm-test-package@2.0.6 publish .
> npm version patch; npm publish
v2.0.7
^C
Why it works crazy? Any hints for me?
Ok, it works after I change to
"push": "npm version patch; npm publish"
So the key word publish
can't be used with npm run
command
Your problem is creating an infinite loop and you have figured that out by yourself.
What you can do is to create a prepublishOnly
script. For example:
{
"prepublishOnly": "npm version patch"
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.