webpack5升级之后npm run serve正常,打包失败?

 "serve": "yarn mark && cross-env MARK_ENV=true USER_ENV=auto vue-cli-service serve",
    "build": "yarn mark && cross-env MARK_ENV=true USER_ENV=production DEPLOY_ENV=deploy vue-cli-service build --mode production",
    "build:dev":"cross-env USER_ENV=development DEPLOY_ENV=deploy node --max_old_space_size=4096 ./node_modules/@vue/cli-service/bin/vue-cli-service.js build  --mode production",
    "build:test": "yarn mark && cross-env MARK_ENV=true USER_ENV=test DEPLOY_ENV=deploy node --max_old_space_size=4096 ./node_modules/@vue/cli-service/bin/vue-cli-service.js build --mode production",
    "build:pre": "yarn mark && cross-env MARK_ENV=true USER_ENV=pre DEPLOY_ENV=deploy node --max_old_space_size=4096 ./node_modules/@vue/cli-service/bin/vue-cli-service.js build --mode production",
    "build:prod": "yarn mark && cross-env MARK_ENV=true USER_ENV=production DEPLOY_ENV=deploy node --max_old_space_size=4096 ./node_modules/@vue/cli-service/bin/vue-cli-service.js build --mode production",

相关依赖如下:

 "dependencies": {
    "@mark/utils": "~1",
    "@vivo/ai-common": "http://npm.vmic.xyz/@vivo%2fai-common/-/ai-common-0.0.4.tgz",
    "@vivo/vi": "http://npm.vmic.xyz/@vivo%2fvi/-/vi-1.0.2.tgz",
    "@vivo/vi-element": "http://npm.vmic.xyz/@vivo%2fvi-element/-/vi-element-2.15.16.tgz",
    "asmcrypto.js": "^2.3.2",
    "axios": "^0.18.1",
    "babel-eslint": "^10.1.0",
    "bignumber.js": "^9.0.1",
    "clipboard": "^2.0.6",
    "core-js": "^3.25.0",
    "dagre": "^0.8.4",
    "dayjs": "^1.9.6",
    "echarts": "^5.4.0",
    "editor.md": "^1.5.0",
    "element-ui": "^2.15.1",
    "happypack": "^5.0.1",
    "html-differ": "^1.4.0",
    "json-format": "^1.0.1",
    "jsonp": "^0.2.1",
    "local": "^0.3.3",
    "lodash": "^4.17.15",
    "markdown": "^0.5.0",
    "monaco-editor": "^0.17.0",
    "node-polyfill-webpack-plugin": "^2.0.1",
    "@mark/babel-plugin-mark": "~1",
    "@mark/vue-cli-plugin-mark": "~1.0.5",
    "nprogress": "^0.2.0",
    "postcss": "^8.4.21",
    "sass": "^1.58.3",
    "sql-formatter": "^2.3.3",
    "store2": "^2.12.0",
    "uuid": "^8.2.0",
    "vue": "^2.6.14",
    "vue-router": "^3.5.1",
    "vue-template-compiler": "^2.6.14",
    "vuex": "^3.6.2",
    "webpack-parallel-uglify-plugin": "^1.1.2"
  },
  "devDependencies": {
    "@babel/core": "^7.12.16",
    "@babel/eslint-parser": "^7.12.16",
    "@commitlint/cli": "^12.1.4",
    "@commitlint/config-conventional": "^12.1.4",
    "@ls-lint/ls-lint": "^1.10.0",
    "@vue/cli-plugin-babel": "~5.0.8",
    "@vue/cli-plugin-eslint": "~5.0.8",
    "@vue/cli-plugin-router": "~5.0.8",
    "@vue/cli-plugin-vuex": "~5.0.8",
    "@vue/cli-service": "~5.0.8",
    "@vue/eslint-config-airbnb": "^6.0.0",
    "add-asset-html-webpack-plugin": "^3.1.3",
    "autoprefixer": "^9.7.6",
    "clean-webpack-plugin": "^3.0.0",
    "compression-webpack-plugin": "^3.0.1",
    "cross-env": "^6.0.3",
    "eslint": "^7.32.0",
    "eslint-plugin-import": "^2.25.3",
    "eslint-plugin-vue": "^8.0.3",
    "eslint-plugin-vuejs-accessibility": "^1.1.0",
    "exports-loader": "^1.1.1",
    "husky": "^6.0.0",
    "lint-staged": "^11.1.2",
    "mockjs": "^1.1.0",
    "postcss-import": "^11.0.0",
    "postcss-loader": "^2.0.8",
    "postcss-url": "^7.2.1",
    "prerender-spa-plugin": "3.4.0",
    "sass-loader": "^13.0.2",
    "script-loader": "^0.7.2",
    "stylelint": "^13.13.1",
    "stylelint-config-standard": "^22.0.0",
    "stylelint-order": "^4.1.0",
    "stylelint-scss": "^3.21.0",
    "webpack": "^5.75.0",
    "webpack-cli": "^5.0.1"
  },

npm run serve: 运行正常
npm run build:dev: 报错

具体报错如下:
image.png
debug.log文件

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'D:\\nvm\\nodejs\\node.exe',
1 verbose cli   'D:\\nvm\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build:dev'
1 verbose cli ]
2 info using npm@6.14.13
3 info using node@v14.17.1
4 verbose run-script [ 'prebuild:dev', 'build:dev', 'postbuild:dev' ]
5 info lifecycle beesapp@1.1.0~prebuild:dev: beesapp@1.1.0
6 info lifecycle beesapp@1.1.0~build:dev: beesapp@1.1.0
7 verbose lifecycle beesapp@1.1.0~build:dev: unsafe-perm in lifecycle true
8 verbose lifecycle beesapp@1.1.0~build:dev: PATH: D:\nvm\v14.17.1\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\Users\72150591\Desktop\bees\beesapp\node_modules\.bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Git\cmd;C:\Program Files\TortoiseGit\bin;%NVM_HOME%;%NVM_SYMLINK%;D:\Users\72150591\AppData\Local\Microsoft\WindowsApps;D:\Users\72150591\AppData\Local\Programs\Microsoft VS Code\bin;D:\nvm;D:\nvm\nodejs
9 verbose lifecycle beesapp@1.1.0~build:dev: CWD: D:\Users\72150591\Desktop\bees\beesapp
10 silly lifecycle beesapp@1.1.0~build:dev: Args: [
10 silly lifecycle   '/d /s /c',
10 silly lifecycle   'cross-env USER_ENV=development DEPLOY_ENV=deploy node --max_old_space_size=4096 ./node_modules/@vue/cli-service/bin/vue-cli-service.js build  --mode production'
10 silly lifecycle ]
11 silly lifecycle beesapp@1.1.0~build:dev: Returned: code: 1  signal: null
12 info lifecycle beesapp@1.1.0~build:dev: Failed to exec build:dev script
13 verbose stack Error: beesapp@1.1.0 build:dev: `cross-env USER_ENV=development DEPLOY_ENV=deploy node --max_old_space_size=4096 ./node_modules/@vue/cli-service/bin/vue-cli-service.js build  --mode production`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (D:\nvm\v14.17.1\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:375:28)
13 verbose stack     at ChildProcess.<anonymous> (D:\nvm\v14.17.1\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:375:28)
13 verbose stack     at maybeClose (internal/child_process.js:1055:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid beesapp@1.1.0
15 verbose cwd D:\Users\72150591\Desktop\bees\beesapp
16 verbose Windows_NT 10.0.22621
17 verbose argv "D:\\nvm\\nodejs\\node.exe" "D:\\nvm\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build:dev"
18 verbose node v14.17.1
19 verbose npm  v6.14.13
20 error code ELIFECYCLE
21 error errno 1
22 error beesapp@1.1.0 build:dev: `cross-env USER_ENV=development DEPLOY_ENV=deploy node --max_old_space_size=4096 ./node_modules/@vue/cli-service/bin/vue-cli-service.js build  --mode production`
22 error Exit status 1
23 error Failed at the beesapp@1.1.0 build:dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
````
阅读 2.5k
3 个回答

你升级 Webpack 之后,对应的 VueCLI 有没有更新呢?
提供一下你的 devDependencies 信息吧。

尝试删除lock文件和node_modules,重新npm i

连接 /src/store/modules.js 时出错,
把最后打印的 debug.log 里去看看是什么错误

同时打开modules.js看看,你import 别的文件的时候有没有大小写错误,windows下就这样,有的时候不区分大小写,有的时候就不行

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏