详细问题描述
【报Bug】uniapp development环境下打包 h5 报错
[内容]
如图:
运行该段指令: "build:h5-dev": "cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-build"
报错: TypeError: Cannot set property 'namedModules' of undefined
定位: @dcloudio/vue-cli-plugin-uni/commands/build.js:90:40
// config.optimization 为 undefined 导致报错
modifyConfig(webpackConfig, config => {
config.optimization.namedModules = false;
});
IDE运行环境说明
vscode 使用 cli 生成的项目
Environment Info:
System:
OS: macOS 10.14.4
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Binaries:
Node: 10.15.3 - /usr/local/bin/node
Yarn: 1.9.4 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Browsers:
Chrome: 75.0.3770.142
Firefox: 67.0.1
Safari: 12.1
npmPackages:
@dcloudio/uni-app-plus: 0.0.243 => 0.0.243
@dcloudio/uni-app-plus-nvue: 0.0.1
@dcloudio/uni-app-plus-nvue-v8: 0.0.1
@dcloudio/uni-cli-shared: => 0.2.973
@dcloudio/uni-h5: 0.5.10 => 0.5.10
@dcloudio/uni-mp-alipay: 0.0.817 => 0.0.817
@dcloudio/uni-mp-baidu: 0.0.844 => 0.0.844
@dcloudio/uni-mp-toutiao: 0.0.341 => 0.0.341
@dcloudio/uni-mp-weixin: 0.0.962 => 0.0.962
@dcloudio/uni-template-compiler: => 0.9.180
@dcloudio/vue-cli-plugin-hbuilderx: ^1.0.121 => 1.0.121
@dcloudio/vue-cli-plugin-uni: ^0.9.497 => 0.9.497
@dcloudio/webpack-uni-mp-loader: => 0.3.639
@dcloudio/webpack-uni-nvue-loader: 0.0.1
@dcloudio/webpack-uni-pages-loader: => 0.2.854
@vue/babel-helper-vue-jsx-merge-props: 1.0.0
@vue/babel-plugin-transform-vue-jsx: 1.0.0
@vue/babel-preset-app: 3.9.2
@vue/babel-preset-jsx: 1.0.0
@vue/babel-sugar-functional-vue: 1.0.0
@vue/babel-sugar-inject-h: 1.0.0
@vue/babel-sugar-v-model: 1.0.0
@vue/babel-sugar-v-on: 1.0.0
@vue/cli-overlay: 3.9.0
@vue/cli-plugin-babel: 3.5.1 => 3.5.1
@vue/cli-service: ^3.0.1 => 3.9.3
@vue/cli-shared-utils: 3.9.0
@vue/component-compiler-utils: 2.6.0 (3.0.0)
@vue/preload-webpack-plugin: 1.1.0
@vue/web-component-wrapper: 1.2.0
mpvue-page-factory: 1.0.1
mpvue-template-compiler: 1.0.13
uni-h5-vue: 2.6.10
uni-mp-vue: 2.6.10
vue: ^2.6.10 => 2.6.10
vue-hot-reload-api: 2.3.3
vue-loader: 15.7.1
vue-router: 3.0.1
vue-style-loader: 3.1.2 (3.1.2)
vue-template-compiler: ^2.6.10 => 2.6.10
vue-template-es2015-compiler: 1.9.1
vuex: ^3.0.1 => 3.1.1
weex-vue-loader: ^0.7.0 => 0.7.0
npmGlobalPackages:
@vue/cli: 3.0.1