dcloudio / uni-app

A cross-platform framework using Vue.js
https://uniapp.dcloud.io
Apache License 2.0
40.18k stars 3.64k forks source link

development 下h5无法打包,一直报错TypeError: Cannot set property 'namedModules' of undefined #569

Closed NickBoomBoom closed 5 years ago

NickBoomBoom commented 5 years ago

uniapp development环境下打包 h5 报错

B7D28DBEFE07BDEA183FBF946A2F7519

运行该段指令: "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

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

NickBoomBoom commented 5 years ago

出现这个问题的原因是否是因为 uni-app build 时支持 production 模式; development 模式下不支持; 如果是这样, 我有些疑惑: uni-app 测试环境的打包 怎么玩

fxy060608 commented 5 years ago

想要 development 模式打包,只是为了不压缩代码吧? 如果是的话

module.exports = {
    configureWebpack: {
        optimization: {
            minimize: false
        }
    }
}
NickBoomBoom commented 5 years ago

想要 development 模式打包,只是为了不压缩代码吧? 如果是的话

module.exports = {
    configureWebpack: {
        optimization: {
            minimize: false
        }
    }
}

不是, 据我现在的了解来看: uni-app 的 H5 dev打包是在内存中的. 在 dist/dev 目录下并没有 H5 项目的文件(即没有测试环境的包)

hbcui1984 commented 5 years ago

想要 development 模式打包,只是为了不压缩代码吧? 如果是的话

module.exports = {
    configureWebpack: {
        optimization: {
            minimize: false
        }
    }
}

不是, 据我现在的了解来看: uni-app 的 H5 dev打包是在内存中的. 在 dist/dev 目录下并没有 H5 项目的文件(即没有测试环境的包)

意思是,让你按照上述配置,但执行build模式,这样即可生成项目目录,也可以不压缩代码,方便调试