当前位置:   article > 正文

vue - vue中npm install安装依赖包 --save,--save-dev,-S,-D的区别_vue --save

vue --save

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"
  }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37

2,–save,–save-dev,-S,-D 这些命令的区别:

  • --save 等同于-S(是前者的缩写):安装包信息将放入到dependencies(生产阶段的依赖,是项目运行时的依赖,程序上线后仍然需要依赖)

使用如下:

  npm install --save  axios
  npm install -S  axios@0.19.0
  加上@0.19.0 是指定版本号;不指定npm默认安装最新的版本;
  • 1
  • 2
  • 3
  • –save-dev等价 于-D(也是前者的缩写):安装包信息将放入到devDependencies(开发阶段的依赖,是我们在开发过程中需要的依赖)

使用如下:

 npm install --save-dev uglifyjs-webpack-plugin
 npm install -D uglifyjs-webpack-plugin
  • 1
  • 2
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/784853
推荐阅读
相关标签
  

闽ICP备14008679号