-S
就是--save
的简写,就行npm默认一个start的字段,你可以不必输入npm run start
而只需输入npm start
,这两个效果是一样的。
-D就是--save-dev 这样安装的包的名称及版本号就会存在package.json的devDependencies这个里面,而--save会将包的名称及版本号放在dependencies里面。
延伸:dependencies是运行时依赖,devDependencies是开发时的依赖
{ "name": "StudyWebpack", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo "Error: no test specified" && exit 1", "dev": "webpack --mode development", "build": "webpack --mode production" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "jquery": "^3.3.1" }, "devDependencies": { "webpack": "^4.16.1", "webpack-cli": "^3.1.0", "webpack-command": "^0.4.1" } }