当前位置:网站首页>npm 模块 移除_【已解决】npm卸载模块后该模块并没有从package.json中去掉[通俗易懂]
npm 模块 移除_【已解决】npm卸载模块后该模块并没有从package.json中去掉[通俗易懂]
2022-07-25 20:53:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
折腾:
期间,遇到一个奇怪的现象:
用npm remove xxx或npm uninstall xxx后
xxx并没有从package.json中去掉:* HeadquarterReport git:(permission-control) * npm remove element-ui
– [email protected] node_modules/async-validator
– [email protected] node_modules/babel-helper-vue-jsx-merge-props
– [email protected] node_modules/deepmerge
– [email protected] node_modules/throttle-debounce
– [email protected] node_modules/element-ui
npm WARN [email protected] No repository field.
结果发现:
package.json
中的配置:
“element-ui”: “1.4.3”,
并没有主动删除掉:
所以再去安装新的:* HeadquarterReport git:(permission-control) * npm install element-ui
[email protected] /Users/crifan/dev/dev_root/xxx
npm WARN [email protected] No repository field.
结果还是1.4.3
after npm uninstall package.json not update
好像要加上:-S, –save参数才能更新package.json?
-》之前也没有加参数,为何可以更新?
再去试了试:* HeadquarterReport git:(permission-control) * npm uninstall element-ui -S
npm WARN [email protected] No repository field.
果然还真的更新了package.json,去掉了element-ui了。
【总结】
npm uninstall/remove xxx
并不能自动更新package.json,把xxx从
dependencies
devDependencies
optionalDependencies
中去掉。
只有加上对应参数才可以:-S, –save:dependencies
-D, –save-dev:devDependencies
-O, –save-optional:optionalDependencies
比如:
npm uninstall element-ui -S
就可以在卸载element-ui的同时,把其从dependencies中删除掉了。
【后记】
后来通过npm install时,结果发现也没有更新package.json:* HeadquarterReport git:(permission-control) * npm install element-ui
[email protected] /Users/crifan/dev/xxxx
npm WARN [email protected] requires a peer of [email protected]^2.5.2 but none was installed.
npm WARN [email protected] No repository field.
没有把element-ui加进去。
after npm install package.json not update
好像也必须是加上参数,才可以?
那就再去试试:* HeadquarterReport git:(permission-control) * npm install element-ui –save
[email protected] /Users/crifan/dev/xxx
npm WARN [email protected] requires a peer of [email protected]^2.5.2 but none was installed.
npm WARN [email protected] No repository field.
果然package.json被更新了,dependencies加上了:
“element-ui”: “^2.0.1”,
【总结2】
看来是:
npm install/uninstall xxx是,只是安装/卸载对应模块
只有加上:
–save
–save-dev
等参数,才能把对应模块版本要求,加入到/删除掉 package.json中。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/127685.html原文链接:https://javaforall.cn
边栏推荐
- [workplace rules] it workplace rules | poor performance
- FanoutExchange交换机代码教程
- “链”接无限可能:数字资产链,精彩马上来!
- Embedded development: embedded foundation -- threads and tasks
- Solution to oom exceptions caused by improper use of multithreading in production environment (supreme Collection Edition)
- [MCU] 51 MCU burning those things
- 476-82(322、64、2、46、62、114)
- 程序的编译和运行
- 数据库清空表数据并让主键从1开始
- seven point two three
猜你喜欢

Success factors of software R & D effectiveness measurement

leetcode-6127:优质数对的数目

Unity vs -- the default debugging in VS is to start rather than attach to unity debugging

Cloud native, Intel arch and cloud native secret computing three sig online sharing! See you today | issues 32-34

Introduction to several scenarios involving programming operation of Excel in SAP implementation project

Canvas fill gradient

LeetCode刷题——猜数字大小II#375#Medium

Detailed explanation of document operation

Compilation and operation of program

Yolov7 training error indexerror: list index out of range
随机推荐
Card link
【单细胞高级绘图】07.KEGG富集结果展示
[noi simulation] string matching (suffix automata Sam, Mo team, block)
Leetcode-155: minimum stack
What's special about Huawei's innovative solutions to consolidate the foundation of ERP for small and medium-sized enterprises?
Cloud native, Intel arch and cloud native secret computing three sig online sharing! See you today | issues 32-34
Remote—实战
[FAQ] access the HMS core push service, and the server sends messages. Cause analysis and solutions of common error codes
Embedded development: embedded foundation -- threads and tasks
Chinese son-in-law OTA Ono became the first Asian president of the University of Michigan, with an annual salary of more than 6.5 million!
Introduction to MySQL engine and InnoDB logical storage structure
leetcode-6125:相等行列对
Niuke-top101-bm38
Character function and string function (2)
Basic knowledge of Marine Geology
Solution to oom exceptions caused by improper use of multithreading in production environment (supreme Collection Edition)
Temperature and humidity environment monitoring system based on stm32
[onnx] export pytorch model to onnx format: support multi parameter and dynamic input
leetcode-6131:不可能得到的最短骰子序列
Brush questions with binary tree (4)