Austin_wcf
Austin_wcf
  • 发布:2022-06-13 21:01
  • 更新:2022-06-14 09:25
  • 阅读:986

【报Bug】控制台报错Uncaught TypeError: Cannot set properties of undefined (setting 'default')

分类:uni-app

产品分类: uniapp/H5

PC开发环境操作系统: Mac

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

浏览器平台: Chrome

浏览器版本: 版本 102.0.5005.61(正式版本)

项目创建方式: CLI

CLI版本号: 2.0.0-28520200811001

示例代码:

System:  
OS: macOS 11.4  
CPU: (6) x64 Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz  
Binaries:  
Node: 14.18.2 - /usr/local/bin/node  
Yarn: 1.22.10 - /usr/local/bin/yarn  
npm: 6.14.15 - /usr/local/bin/npm  
Browsers:  
Chrome: 102.0.5005.61  
Firefox: 100.0  
Safari: 14.1.1  
npmPackages:  
@dcloudio/types: * => 2.6.11  
@dcloudio/uni-app-plus: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/uni-app-plus-nvue: 0.0.1  
@dcloudio/uni-app-plus-nvue-v8: 0.0.1  
@dcloudio/uni-automator: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/uni-cli-shared: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/uni-h5: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/uni-helper-json: * => 1.0.13  
@dcloudio/uni-migration: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/uni-mp-360: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/uni-mp-alipay: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/uni-mp-baidu: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/uni-mp-qq: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/uni-mp-toutiao: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/uni-mp-vue: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/uni-mp-weixin: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/uni-quickapp-native: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/uni-quickapp-webview: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/uni-stat: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/uni-template-compiler: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/vue-cli-plugin-hbuilderx: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/vue-cli-plugin-uni: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/vue-cli-plugin-uni-optimize: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/webpack-uni-mp-loader: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@dcloudio/webpack-uni-nvue-loader: 0.0.1  
@dcloudio/webpack-uni-pages-loader: 2.0.0-32320210825001 => 2.0.0-32320210825001  
@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 => 4.5.17  
@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.17  
@vue/cli-plugin-babel: ~4.5.0 => 4.5.17  
@vue/cli-plugin-eslint: ^4.5.4 => 4.5.17  
@vue/cli-plugin-router: 4.5.17  
@vue/cli-plugin-vuex: 4.5.17  
@vue/cli-service: ~4.5.0 => 4.5.17  
@vue/cli-shared-utils: 4.5.17  
@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/reactivity: 3.0.5  
@vue/shared: ^3.0.0 => 3.2.37  
@vue/web-component-wrapper: 1.3.0  
eslint-plugin-vue: ^6.2.0 => 6.2.2  
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-eslint-parser: 7.11.0  
vue-hot-reload-api: 2.3.4  
vue-jsonp: ^2.0.0 => 2.0.0  
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  
vuex: ^3.2.0 => 3.6.2 (3.6.2)  
npmGlobalPackages:  
@vue/cli: 3.12.1  

设备信息 [如 iPhone8 Plus]  
package.json文件  
{  
"name": "project",  
"version": "2.5.5",  
"description": "xxxxx ",  
"private": true,  
"scripts": {  
"serve": "npm run dev:h5",  
"build": "npm run build:h5",  
"build-test": "npm run build:h5:test",  
"build-pre": "npm run build:h5:pre",  
"start": "concurrently 'npm run dev:mp-weixin' 'npm run doc'",  
"doc": "cd ./doc && npm i && npm run serve",  
"lint": "vue-cli-service lint",  
"build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 VUE_APP_ENV=production vue-cli-service uni-build",  
"build:h5:pre": "cross-env NODE_ENV=production UNI_PLATFORM=h5 VUE_APP_ENV=pre vue-cli-service uni-build",  
"build:h5:test": "cross-env NODE_ENV=production UNI_PLATFORM=h5 VUE_APP_ENV=test vue-cli-service uni-build",  
"build:mp-baidu": "cross-env NODE_ENV=production UNI_PLATFORM=mp-baidu VUE_APP_ENV=production vue-cli-service uni-build",  
"build:mp-qq": "cross-env NODE_ENV=production UNI_PLATFORM=mp-qq VUE_APP_ENV=production vue-cli-service uni-build",  
"build:mp-toutiao": "cross-env NODE_ENV=production UNI_PLATFORM=mp-toutiao VUE_APP_ENV=production vue-cli-service uni-build",  
"build:mp-weixin": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin VUE_APP_ENV=production vue-cli-service uni-build",  
"build:mp-weixin:dev": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin VUE_APP_ENV=development vue-cli-service uni-build",  
"build:mp-weixin:test": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin VUE_APP_ENV=test vue-cli-service uni-build",  
"build:mp-weixin:pre": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin VUE_APP_ENV=pre vue-cli-service uni-build",  
"dev:h5": "cross-env NODE_ENV=development UNI_PLATFORM=h5 VUE_APP_ENV=development vue-cli-service uni-serve",  
"dev:mp-baidu": "cross-env NODE_ENV=development UNI_PLATFORM=mp-baidu VUE_APP_ENV=development vue-cli-service uni-build --watch",  
"dev:mp-qq": "cross-env NODE_ENV=development UNI_PLATFORM=mp-qq VUE_APP_ENV=development vue-cli-service uni-build --watch",  
"dev:mp-toutiao": "cross-env NODE_ENV=development UNI_PLATFORM=mp-toutiao VUE_APP_ENV=development vue-cli-service uni-build --watch",  
"dev:mp-weixin": "cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin VUE_APP_ENV=development vue-cli-service uni-build --watch --minimize",  
"info": "node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.js",  
"deploy": "node script/deploy.js",  
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",  
"release": "node script/release.js",  
"ci-preview": "node ci/preview.js",  
"ci-deploy": "node ci/deploy.js"  
},  
"dependencies": {  
"@babel/polyfill": "^7.12.1",  
"@dcloudio/uni-app-plus": "2.0.0-32320210825001",  
"@dcloudio/uni-h5": "2.0.0-32320210825001",  
"@dcloudio/uni-helper-json": "",  
"@dcloudio/uni-mp-360": "2.0.0-32320210825001",  
"@dcloudio/uni-mp-alipay": "2.0.0-32320210825001",  
"@dcloudio/uni-mp-baidu": "2.0.0-32320210825001",  
"@dcloudio/uni-mp-qq": "2.0.0-32320210825001",  
"@dcloudio/uni-mp-toutiao": "2.0.0-32320210825001",  
"@dcloudio/uni-mp-vue": "2.0.0-32320210825001",  
"@dcloudio/uni-mp-weixin": "2.0.0-32320210825001",  
"@dcloudio/uni-quickapp-native": "2.0.0-32320210825001",  
"@dcloudio/uni-quickapp-webview": "2.0.0-32320210825001",  
"@dcloudio/uni-stat": "2.0.0-32320210825001",  
"@ideamake/sw-mini-ui": "^1.19.26",  
"@ideamake/sw-tracker-uni": "^1.0.24",  
"@vue/babel-preset-app": "^4.5.15",  
"@vue/shared": "^3.0.0",  
"core-js": "^3.6.5",  
"cos-wx-sdk-v5": "^0.7.10",  
"dayjs": "^1.8.34",  
"flyio": "^0.6.2",  
"js-md5": "^0.7.3",  
"lottie-web": "^5.8.1",  
"lottiejs-miniapp": "^1.1.0",  
"mescroll-uni": "^1.3.2",  
"qs": "6.9.6",  
"regenerator-runtime": "^0.12.1",  
"tim-wx-sdk": "^2.7.7",  
"vue": "^2.6.11",  
"vue-jsonp": "^2.0.0",  
"vuex": "^3.2.0"  
},  
"devDependencies": {  
"@babel/runtime": "~7.12.0",  
"@commitlint/cli": "^9.1.2",  
"@commitlint/config-conventional": "^9.1.2",  
"@dcloudio/types": "",  
"@dcloudio/uni-automator": "2.0.0-32320210825001",  
"@dcloudio/uni-cli-shared": "2.0.0-32320210825001",  
"@dcloudio/uni-migration": "2.0.0-32320210825001",  
"@dcloudio/uni-template-compiler": "2.0.0-32320210825001",  
"@dcloudio/vue-cli-plugin-hbuilderx": "2.0.0-32320210825001",  
"@dcloudio/vue-cli-plugin-uni": "2.0.0-32320210825001",  
"@dcloudio/vue-cli-plugin-uni-optimize": "2.0.0-32320210825001",  
"@dcloudio/webpack-uni-mp-loader": "2.0.0-32320210825001",  
"@dcloudio/webpack-uni-pages-loader": "2.0.0-32320210825001",  
"@vue/cli-plugin-babel": "~4.5.0",  
"@vue/cli-plugin-eslint": "^4.5.4",  
"@vue/cli-service": "~4.5.0",  
"babel-eslint": "^10.0.1",  
"babel-plugin-import": "^1.11.0",  
"commitizen": "^4.2.0",  
"component-placeholder-plugin": "^1.0.14",  
"concurrently": "^5.3.0",  
"conventional-changelog-cli": "^2.1.0",  
"cross-env": "^7.0.2",  
"cz-conventional-changelog": "^3.2.1",  
"eslint": "^7.0.0",  
"eslint-plugin-vue": "^6.2.0",  
"husky": "^4.2.5",  
"inquirer": "^7.3.3",  
"lint-staged": "^8.1.5",  
"mini-types": "",  
"miniprogram-api-typings": "",  
"miniprogram-ci": "^1.2.3",  
"mvdir": "^1.0.17",  
"postcss-comment": "^2.0.0",  
"sass": "^1.46.0",  
"sass-loader": "10.1.1",  
"shelljs": "^0.8.4",  
"standard-version": "^9.0.0",  
"strip-json-comments": "^3.1.1",  
"stylelint": "^13.7.2",  
"stylelint-config-standard": "^20.0.0",  
"stylelint-order": "^4.1.0",  
"stylelint-scss": "^3.18.0",  
"stylelint-webpack-plugin": "^2.1.0",  
"vue-template-compiler": "^2.6.11",  
"yorkie": "^2.0.0"  
},  
"eslintConfig": {  
"root": true,  
"env": {  
"node": true  
},  
"extends": [  
"plugin:vue/essential",  
"@vue/standard"  
],  
"rules": {},  
"parserOptions": {  
"parser": "babel-eslint"  
}  
},  
"browserslist": [  
"last 1 versions",  
"defaults"  
],  
"husky": {  
"hooks": {  
"pre-commit": "lint-staged",  
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"  
}  
},  
"config": {  
"commitizen": {  
"path": "./node_modules/cz-conventional-changelog"  
}  
},  
"commitlint": {  
"extends": [  
"@commitlint/config-conventional"  
]  
},  
"lint-staged": {  
"linters": {  
"*.{js,jsx,vue}": [  
"vue-cli-service lint",  
"git add"  
]  
},  
"ignore": [  
"doc",  
"src/styles/mixins.scss"  
]  
}  
}  

操作步骤:

uniapp项目历史项目(版本:3.2.3.20210825),删除package-lock.json文件
重新安装包npm i
打开http://localhost:8080/#/
打开控制台页面空白页,控制台报错chunk-vendors.js:41028 Uncaught TypeError: Cannot set properties of undefined (setting 'default')

预期结果:

控制台不报错,项目正常运行

实际结果:

项目编译不报错,控制台报错,空白页

bug描述:

uniapp项目历史项目(版本:3.2.3.20210825),删除package-lock.json文件,重新安装包后, 编译为h5项目npm run dev:h5,编译没有报错,但是项目是空白页,控制台报错

chunk-vendors.js:41028 Uncaught TypeError: Cannot set properties of undefined (setting 'default')

2022-06-13 21:01 负责人:无 分享
已邀请:
DCloud_UNI_WZF

DCloud_UNI_WZF

参考 这里 的解决方案试下,如无法解决请在本帖继续回复,我会跟进,谢谢!

  • Austin_wcf (作者)

    看了下你这边提供解决方案,无法解决我的问题,我这边也是用npm安装的包,还是报错,辛苦帮忙跟进一下了,谢谢哈

    2022-06-14 09:49

  • DCloud_UNI_WZF

    回复 Austin_wcf: @babel/runtime 版本改了吗,node 版本多少,可以提供个可复现demo吗

    2022-06-14 10:20

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