赞
踩
vue中npm install安装依赖包 --save,–save-dev,-S,-D的区别;先介绍package.json里面的
dependencies
模块和devDependencies
的区别;
1,dependencies和devDependencies的区别:
**dependencies
**是生产时的依赖:比如:vue, axios,echarts,element-ui,vant等这些项目打包后也依旧就能够用到的重要依赖;
**devDependencies
**是开发时的依赖:比如:eslint,prettier代码美化和检查,sass-loader css预编译,babel es6转es5,uglifyjs-webpack-plugin js代码压缩,image-webpack-loader 图片压缩 等这些
loder , plugin, babel, webpack类的辅助开发或只在打包阶段使用的;不会再生产中使用的依赖我们要放在devDependencies模块里面;
"dependencies": { "axios": "^0.19.0", "core-js": "^3.6.5", "echarts": "^5.3.3", "element-ui": "2.12.0", "html2canvas": "1.0.0-rc.7", "qrcodejs2": "^0.0.2", "recorder-core": "1.1.21021500", "vant": "^2.12.8", "vconsole": "^3.14.6", "vue": "^2.6.11", "vue-cli-plugin-mock": "^1.0.3", "vue-router": "^3.2.0", "vuex": "^3.4.0", "vuex-persistedstate": "^4.1.0", "xgplayer": "^2.31.6" }, "devDependencies": { "@vue/cli-plugin-babel": "~4.5.0", "@vue/cli-plugin-eslint": "~4.5.0", "@vue/cli-plugin-router": "~4.5.0", "@vue/cli-plugin-vuex": "~4.5.0", "@vue/cli-service": "~4.5.0", "@vue/eslint-config-prettier": "^6.0.0", "babel-eslint": "^10.1.0", "babel-plugin-component": "^1.1.1", "babel-plugin-import": "^1.13.3", "eslint": "^6.7.2", "uglifyjs-webpack-plugin": "^2.2.0", "eslint-plugin-prettier": "^3.3.1", "eslint-plugin-vue": "^6.2.2", "image-webpack-loader": "^8.1.0", "node-sass": "^4.14.1", "prettier": "^2.2.1", "sass-loader": "^8.0.2", "vue-template-compiler": "^2.6.11" }
2,–save,–save-dev,-S,-D 这些命令的区别:
--save 等同于-S
(是前者的缩写):安装包信息将放入到dependencies(生产阶段的依赖,是项目运行时的依赖,程序上线后仍然需要依赖)使用如下:
npm install --save axios
npm install -S axios@0.19.0
加上@0.19.0 是指定版本号;不指定npm默认安装最新的版本;
–save-dev等价 于-D
(也是前者的缩写):安装包信息将放入到devDependencies(开发阶段的依赖,是我们在开发过程中需要的依赖)使用如下:
npm install --save-dev uglifyjs-webpack-plugin
npm install -D uglifyjs-webpack-plugin
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。