admin管理员组文章数量:1410730
Prior to publishing to NPM I need to bump the minor version. What I usually do is:
- Change package.json
- Run npm i
which syncs package-lock.json
with the change. Now both can be published.
Is there a way to do this with a single NPM mand?
Prior to publishing to NPM I need to bump the minor version. What I usually do is:
- Change package.json
- Run npm i
which syncs package-lock.json
with the change. Now both can be published.
Is there a way to do this with a single NPM mand?
Share Improve this question edited Mar 19, 2019 at 2:55 Ole asked Mar 18, 2019 at 11:46 OleOle 47.5k70 gold badges238 silver badges445 bronze badges3 Answers
Reset to default 6Use npm version.
For example, the following mand
npm version 1.0.2
will bump both package.json
and package-lock.json
to 1.0.2
The following mand
npm i -S <module>@<version>
installs the specific version of the given module.
-S
or --save
tells npm to save the reference of the module + version into both package.json
and package-lock.json
It depends on the granularity of control you want to have. For example, if you just want to check for an update on an individual module you can run: npm update <pkg>
. As this mand will update your package.json
file to save the newest version of this <pkg>
as the now required version to build your project. Alternatively, you could run npm update
to update all your project's top-level packages. Ok so those are the more general use cases but if you want a specific version of a package and you know the version of which you desire you can do the following: npm i --save <pkg>@<version>
as this mand will grab the package specified by your version number as well as update the package.json
file to include this version of package as now being required to build your project. This will eliminate the need to first update the package.json
file and then installing the newer version of said package, rather this will be condensed down to one step. Lastly, just for thoroughness the package-lock.json
file is dynamically generated when you make important changes to your project, such as requiring new dependencies or updating existing dependencies. This file kind of serves as source of truth so others can build your project and have the same setup as you, for more information on this file take a look at the npm docs
Hopefully that helps!
本文标签: javascriptBumping packagelockjson and packgelock at the same timeStack Overflow
版权声明:本文标题:javascript - Bumping package-lock.json and packge.lock at the same time? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745031072a2638500.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论