在npm中
-D 就是 –save-dev的简写,
-S 就是 –save 的简写;
dev其实就是 develop的简写,也就是开发的意思
我们在安装工具包之前常常先写入npm init -y 来创建package.json帮我们记录包的名称以及版本号等等,而通过输入 -D 命令时,包的名称及版本号就会在 devDependencies 中显示,输入 -S 命令时,包的名称及版本号就在 dependencies 中显示。
devDependencies即开发依赖,只在开发时使用,产品上线时不需要
dependencies即生产依赖,在生产环境中使用。
输入 -D 时
{
"name": "webpack-basic",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"webpack": "^4.29.6"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
输入 -S 时
{
"name": "webpack-basic",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"webpack": "^4.29.6"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}