Vue从入门到实战:package.json

来自CloudWiki
跳转至: 导航搜索

简介

这是一个JSON格式的npm配置文件,定义了项目所需要的各种模块,以及项目的配置信息。


{
  "name": "helloworld",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.6.5",
    "vue": "^2.6.11"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-vue": "^6.2.2",
    "vue-template-compiler": "^2.6.11"
  }
}

在使用NPM安装依赖的模块时,可以根据模块是否需要在生产环境下使用而选择附加-S(--save)或-D(--save-dev)参数

npm install element-ui -S

安装后会在dependencies中写入依赖项,项目发布时,依赖项也一起打包。

如果模块只在开发环境下使用,则可以使用-D参数来安装。

下载了别人的代码后,怎么安装依赖呢 ?执行npm install 命令。