admin管理员组文章数量:1319478
If I uninstall a package from my project like this:
npm uninstall react
the line related to this package in package.json file does not disappear, and then when I install a different version of this package, like this:
npm install [email protected]
the package gets installed to the node_modules, but the version in package.json remains to be unupdated, meaning that it is still the old version of a package, that I had before the uninstallation.
How to delete / update / change the version in package.json through terminal?
If I uninstall a package from my project like this:
npm uninstall react
the line related to this package in package.json file does not disappear, and then when I install a different version of this package, like this:
npm install [email protected]
the package gets installed to the node_modules, but the version in package.json remains to be unupdated, meaning that it is still the old version of a package, that I had before the uninstallation.
How to delete / update / change the version in package.json through terminal?
Share Improve this question asked Sep 28, 2017 at 13:22 EduardEduard 9,21511 gold badges46 silver badges72 bronze badges 2-
What version of
npm
are you using? Did you notice a file calledpackage-lock.json
? – msanford Commented Sep 28, 2017 at 13:29 -
Also,
ncu
may be useful for you: npmjs./package/npm-check-updates – msanford Commented Sep 28, 2017 at 13:31
2 Answers
Reset to default 5You need to add --save
to the mand in both install and uninstall cases.
This way, when uninstalling with --save, the package's line will be erased from package.json as well as from node_modules. And when installing with --save, the package's line will be added to the package.json, as well as the node_modules.
So, you should go like that, for example:
npm uninstall react --save
npm install [email protected] --save
Since the question asked about changing the version in package.json
, I'll add a quick answer showing that. Simply change the line in package.json
to specify the exact version like so:
"react": "15.0.0",
save, and then run npm install
.
You can check which exact version is installed by looking in package-lock.json
as well.
本文标签: javascriptHow to change the version of package in packagejsonStack Overflow
版权声明:本文标题:javascript - How to change the version of package in package.json - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742058673a2418451.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论