Inside a Node.js project, it's not clear to me what the correct workflow would be to upgrade a package to a major release.
Let's suppose I'm installing stylelint:
npm install --save stylelint
By default that installation puts the string "stylelint": "^8.4.1"
inside my package.json file, which means that if I want to update it with npm update
, I will get only minor and patch releases (8.4.2 is ok, 8.5.0 is ok, 9.0.0 is not).
If I check with npm outdated
and it comes out that I could update to 9.0.0, npm update
won't get me to that state because of the restriction depicted above.
So, if I want to upgrade, what am I supposed to do?
Must I manually modify my package.json to stylelint version ^9.0.0, delete the node_modules
directory, and re-run npm install
?
Or should I remove the ^
character to let npm update
do its job?
What is the common/best practice to adopt?
npm update
only takes care of only minor and patch upgrade. However, for updating the major version intentionally, you could usenpm install
command without uninstall or manual removal. for your e.g.npm install [email protected]
ornpm install stylelint@latest