Kindi丶
Kindi丶
  • 发布:2021-07-28 14:05
  • 更新:2021-12-02 11:23
  • 阅读:1182

【报Bug】cli创建项目运行小程序报错:TypeError: Cannot read property 'config' of undefined

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: 11.4

第三方开发者工具版本号: 1.05.2107221

基础库版本号: 2.18.1

项目创建方式: CLI

CLI版本号: @vue/cli 4.5.13

操作步骤:

根据文档 vue create -p dcloudio/uni-preset-vue my-project 生成项目,一个字都未改动,直接运行 yarn dev:mp-weixin,然后用小程序开发工具打开dist/dev/mp-weixin

预期结果:

正常运行

实际结果:
app.js错误:  
 TypeError: Cannot read property 'config' of undefined  
    at Object.<anonymous> (main.js? [sm]:4)  
    at Object.<anonymous> (main.js? [sm]:11)  
    at __webpack_require__ (bootstrap:81)  
    at checkDeferredModules (bootstrap:47)  
    at Array.webpackJsonpCallback [as push] (bootstrap:34)  
    at main.js:4  
    at require (VM57 WAService.js:2)  
    at r (VM57 WAService.js:2)  
    at app.js? [sm]:4  
    at require (VM57 WAService.js:2)(env: macOS,mp,1.05.2107221; lib: 2.18.1)

bug描述:

根据文档 vue create -p dcloudio/uni-preset-vue my-project 生成项目,一个字都未改动,直接运行 yarn dev:mp-weixin,然后用小程序开发工具打开dist/dev/mp-weixin,控制台提示:

app.js错误:  
 TypeError: Cannot read property 'config' of undefined  
    at Object.<anonymous> (main.js? [sm]:4)  
    at Object.<anonymous> (main.js? [sm]:11)  
    at __webpack_require__ (bootstrap:81)  
    at checkDeferredModules (bootstrap:47)  
    at Array.webpackJsonpCallback [as push] (bootstrap:34)  
    at main.js:4  
    at require (VM57 WAService.js:2)  
    at r (VM57 WAService.js:2)  
    at app.js? [sm]:4  
    at require (VM57 WAService.js:2)(env: macOS,mp,1.05.2107221; lib: 2.18.1)
2021-07-28 14:05 负责人:无 分享
已邀请:
落雁still飞

落雁still飞

请问解决了么 我也报了。。
是不是vue-cli版本问题

DCloud_UNI_GSQ

DCloud_UNI_GSQ

npm run info 打印一下依赖信息

m***@gmail.com

m***@gmail.com

请问解决了么
vue-cli4.5.9

npm run info 的信息

uni-app v3.2.12
uni-app cli v2.0.0-32920211029004

Environment Info:

System:
OS: macOS 11.6.1
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Binaries:
Node: 15.5.0 - ~/.nvm/versions/node/v15.5.0/bin/node
Yarn: Not Found
npm: 7.6.3 - ~/.nvm/versions/node/v15.5.0/bin/npm
Browsers:
Chrome: 95.0.4638.69
Firefox: 94.0.1
Safari: 15.1

npmPackages:
@dcloudio/types: => 2.5.13
@dcloudio/uni-app-plus: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-app-plus-nvue: 0.0.1
@dcloudio/uni-app-plus-nvue-v8: 0.0.1
@dcloudio/uni-automator: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-cli-i18n: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-cli-shared: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-h5: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-helper-json:
=> 1.0.13
@dcloudio/uni-i18n: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-migration: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-mp-360: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-mp-alipay: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-mp-baidu: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-mp-kuaishou: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-mp-qq: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-mp-toutiao: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-mp-vue: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-mp-weixin: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-quickapp-native: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-quickapp-webview: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-stat: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/uni-template-compiler: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/vue-cli-plugin-hbuilderx: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/vue-cli-plugin-uni: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/vue-cli-plugin-uni-optimize: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/webpack-uni-mp-loader: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@dcloudio/webpack-uni-nvue-loader: 0.0.1
@dcloudio/webpack-uni-pages-loader: ^2.0.0-32920211029004 => 2.0.0-32920211029004
@hap-toolkit/dsl-vue: 0.6.13
@vue/babel-helper-vue-jsx-merge-props: 1.2.1
@vue/babel-helper-vue-transform-on: 1.0.2
@vue/babel-plugin-jsx: 1.1.1
@vue/babel-plugin-transform-vue-jsx: 1.2.1
@vue/babel-preset-app: 4.5.15
@vue/babel-preset-jsx: 1.2.4
@vue/babel-sugar-composition-api-inject-h: 1.2.1
@vue/babel-sugar-composition-api-render-instance: 1.2.4
@vue/babel-sugar-functional-vue: 1.2.2
@vue/babel-sugar-inject-h: 1.2.2
@vue/babel-sugar-v-model: 1.2.3
@vue/babel-sugar-v-on: 1.2.3
@vue/cli-overlay: 4.5.15
@vue/cli-plugin-babel: ~4.5.0 => 4.5.15
@vue/cli-plugin-router: 4.5.15
@vue/cli-plugin-vuex: 4.5.15
@vue/cli-service: ~4.5.0 => 4.5.15
@vue/cli-shared-utils: 4.5.15
@vue/component-compiler-utils: 3.3.0 (3.3.0)
@vue/devtools-api: 6.0.0-beta.15
@vue/preload-webpack-plugin: 1.1.2
@vue/shared: ^3.0.0 => 3.2.21
@vue/web-component-wrapper: 1.3.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.11 => 2.6.14
vue-hot-reload-api: 2.3.4
vue-loader: 15.9.8 (16.8.3, 15.9.8)
vue-router: 3.0.1
vue-style-loader: 4.1.3 (4.1.3)
vue-template-compiler: ^2.6.11 => 2.6.14 (2.6.14)
vue-template-es2015-compiler: 1.9.1
vue3: 1.0.0
vuex: ^3.2.0 => 3.6.2 (3.6.2)
npmGlobalPackages:
@vue/cli: Not Found

4***@qq.com

4***@qq.com

同样的问题

1***@qq.com

1***@qq.com

这错误我也遇到了,因为之前一直是没问题的,所有配置我都有记录,但是创建新的默认模板就是会报错,后来发现是默认模板中多了一些vue3的参数导致的

没错说的就是根目录中vue.config.js

process.env.UNI_USING_VUE3 = true  
process.env.UNI_USING_VUE3_OPTIONS_API = true

这两行

直接改为false还没用,需要删掉或者注释掉

该问题目前已经被锁定, 无法添加新回复