vue-element-admin打包时报此错

233 阅读1分钟

项目执行打包命令

npm run build

出现报错信息:

C:\userdata\vue-element-admin>npm run build
npm ERR! missing script: build

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\mundo\AppData\Roaming\npm-cache\_logs\2021-11-12T02_18_03_768Z-debug.log

C:\userdata\vue-element-admin>npm run build
npm ERR! missing script: build

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\mundo\AppData\Roaming\npm-cache\_logs\2021-11-12T02_18_33_493Z-debug.log

C:\userdata\vue-element-admin>

因package.json中scripts是这样的,执行命令时需要指定环境

"scripts": {
    "dev": "vue-cli-service serve",
    "lint": "eslint --ext .js,.vue src",
    "build:prod": "vue-cli-service build",
    "build:stage": "vue-cli-service build --mode staging",
    "preview": "node build/index.js --preview",
    "new": "plop",
    "svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml",
    "test:unit": "jest --clearCache && vue-cli-service test:unit",
    "test:ci": "npm run lint && npm run test:unit"
  },

执行命令按

npm run build:prod

npm run build:stage

就不会报错了。