当前位置:网站首页>npm install -g/--save/--save-dev的区别
npm install -g/--save/--save-dev的区别
2022-07-05 06:41:00 【海底烧烤店ai】
npm install XX (简写为npm i XX)
- 会把
XX
包安装到node_modules
目录中 - 在
npm5
版本之前,XX
不会自动写入package.json
- 在
npm5
之后会自动写入package.json
的dependencies
属性中(与--save
相同)
npm install XX -g
-g
的意思是将模块安装到全局,具体安装到磁盘哪个位置,要看npm config prefix
的位置具体查看方法是在终端输入
npm config edit
,在弹出的文档中找到;prefix=C:\node
就是了
npm install XX --save(简写为npm i XX -S)
会把
XX
包安装到node_modules
目录中,会在
package.json
的dependencies
属性下添加XX
-运行
npm install --production
或者注明NODE_ENV
变量值为production
时(生产环境下安装依赖),会自动下载模块到node_modules
目录中。在
npm5
之后可以被npm i xx
替代
dependencies
中的依赖是生产环境中的依赖,在项目部署后的生产环境中也会被安装,例如:
用了
axios
请求,由于发布到生产后还是要用到axios
,这就可以将axios
安装到dependencies
npm install XX --save-dev(简写为npm i XX -D)
会把
XX
包安装到node_modules
目录中会在
package.json
的devDependencies
属性下添加XX
运行
npm install --production
或者注明NODE_ENV
变量值为production
时(生产环境下安装依赖),不会自动下载模块到node_modules
目录中。
devDependencies
中的依赖是仅在开发环境中的依赖,在项目部署后的生产环境中不会被安装,例如:
写
ES6
代码时,需要babel
转换成es5
,转换完成后,我们只需要转换后的代码,上线的时候,直接把转换后的代码部署到生产环境,不需要bebal
了,生产环境不需要,这就可以将babel
安装到devDependencies
边栏推荐
猜你喜欢
Orin installs CUDA environment
ethtool 原理介绍和解决网卡丢包排查思路(附ethtool源码下载)
Ros2 - first acquaintance with ros2 (I)
[MySQL 8.0 does not support capitalization of table names - corresponding scheme]
并发编程 — 如何中断/停止一个运行中的线程?
Ros2 - node (VII)
Skywalking全部
Instruction execution time
Vant weave swipecell sets multiple buttons
Ret2xx---- common CTF template proposition in PWN
随机推荐
Xavier CPU & GPU 高负载功耗测试
7. Oracle table structure
Genesis builds a new generation of credit system
VLAN experiment
Preemption of CFS scheduling
6-4 search by serial number of linked list
MPLS experiment
微信小程序路由再次跳轉不觸發onload
【MySQL8.0不支持表名大写-对应方案】
How to answer when you encounter a jet on CSDN?
Xavier CPU & GPU high load power consumption test
testing framework
Marvell 88E1515 PHY loopback模式测试
The differences and connections among cookies, sessions, JWT, and tokens
2022年中纪实 -- 一个普通人的经历
[Chongqing Guangdong education] National Open University 2018 autumn 0702-22t contemporary Chinese political system reference questions
Sre core system understanding
基于Cortex-M3、M4的GPIO口位带操作宏定义(可总线输入输出,可用于STM32、ADuCM4050等)
PR automatically moves forward after deleting clips
【软件测试】02 -- 软件缺陷管理