当前位置:网站首页>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
边栏推荐
- preprocessor directives
- Focus on data | Haitai Fangyuan directly hits the construction idea of data security governance in the securities industry
- [workplace rules] it workplace rules | poor performance
- [MSA] a brief description of the moveit Configuration Assistant chain in planning groups
- C language file reading and writing
- Remote - actual combat
- [noi simulation] string matching (suffix automata Sam, Mo team, block)
- Opencv learning Fourier transform experience and line direction Fourier transform code
- 【网络教程】IPtables官方教程--学习笔记2
- Unity vs -- the default debugging in VS is to start rather than attach to unity debugging
猜你喜欢

Remote—基本原理介绍

Focus on data | Haitai Fangyuan directly hits the construction idea of data security governance in the securities industry

leetcode-919:完全二叉树插入器
![Vulnhub | dc: 6 | [actual combat]](/img/7e/de7d5b56724bde5db2bb8338c35aa8.png)
Vulnhub | dc: 6 | [actual combat]

How to use buffer queue to realize high concurrent order business (glory Collection Edition)

Kubernetes进阶部分学习笔记

【ONNX】pytorch模型导出成ONNX格式:支持多参数与动态输入

Online XML to JSON tool

ROS_ Rqt toolbox

基于腾讯地图实现精准定位,实现微信小程序考勤打卡功能
随机推荐
Niuke-top101-bm38
Explain the principle of MySQL master-slave replication in detail
Differences between seaslog and monolog log systems, installation steps of seaslog [easy to understand]
Principle analysis of bootloader
leetcode-6125:相等行列对
preprocessor directives
Learn FPGA from the bottom structure (16) -- customization and testing of pll/mmcm IP
Remote—实战
Recommend a website that converts curl commands into PHP code & a website that initiates and executes curl requests online
In June 2021, the interview suffered a Waterloo. Is it so convoluted now
leetcode-6129:全 0 子数组的数目
Force deduction ----- calculate the money of the force deduction bank
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!
The uniapp project starts with an error binding Node is not a valid Win32 Application ultimate solution
Leetcode-79: word search
[fiddlertx plug-in] use Fiddler to capture the package Tencent classroom video download (unable to capture the package solution)
一道golang中关于recover的面试题
Automated testing ----- selenium (I)
测试用例和缺陷报告模板
476-82(322、64、2、46、62、114)