Obviously if you try to npm publish
without updating the version number of your module you will get an error. Is there any way to verify that the version number is valid for publishing before actually running npm publish
?
My use case: I'm using CircleCI to build my module when pushing to any git branch. If somebody creates a pull request to master, I want to verify that the version number has been updated. However, I don't want to actually publish the package until the pull request to master has been accepted.
After changing the version number in your package. json , you can run npm publish to publish the new version to NPM. npm install will install the latest version in the NPM repository.
json and publish it to npm using the same version. You can't publish again using the same version, or a previous one. You can read more about versioning here. Don't forget to build before publishing.
You can get your current package version by: npm view <pkg> version
(npm v5), than compare it with the version in the code.
It is easy to check whether the version has change, a simple ===
is enough. If you need to check whether the new version is valid, you should use look for a module for that.
https://www.npmjs.com/package/semver for example if you use JS code to check, or https://github.com/cloudflare/semver_bash if you use bash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With