I can see at https://docs.npmjs.com/getting-started/publishing-npm-packages, that npm version <update_type>
changes the version number in package.json
(also add a tag with this release number to your git repository if you have one). Then, with npm publish
the change is commited and the package updated.
I have a repository in Github which is published in NPM.
The question is: do I have to commit my changes
explicitly before npm version <update_type>
or npm publish
, or will npm publish
take care of it.
This is an example of how I proceed now:
Make some changes
Execute the next commands:
git add .
git commit -m "Message"
npm version minor
npm publish
This is what I'm not sure if will work:
Make some changes
Execute the next commands:
npm version minor
npm publish
Edit:
In fact, if I execute npm version minor
without committing the changes before, I get this error:
npm ERR! Git working directory not clean.
So the answer would be: Yes, I have to commit my changes explicitly before npm version <update_type>
.
The question is: do I have to commit my changes explicitly before npm version or npm publish, or will npm publish take care of it.
The act of publishing to NPM is independent from committing and pushing to a Git repo.
So, no, you do not need to commit before publishing, and NPM will not commit for you.
But, you should still strive to have your Git repository match your NPM versions. For example, you could tag important commits that correspond to a particular release.
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