Closed WEI4D closed 2 years ago
使用 npm 安装依赖可解决该问题,yarn install 报错的原因是因为 npm 和 yarn 安装依赖时合并策略不同,导致依赖版本与预期不同导致。 如果仍要通过 yarn 管理依赖,可修改项目根目录 package.json 中 devDeps 依赖 @babel/runtime 的版本为 ~7.17.9,并增加
"resolutions":{
"@babel/runtime": "~7.17.9"
}
锁定该依赖版本。
问题描述 H5端 同一个项目在执行
npm i
项目可以正常运行 而使用:yarn Install
后,运行项目,在浏览器控制台报错:Uncaught TypeError: Cannot set properties of undefined (setting 'default') at _regeneratorRuntime (chunk-vendors.js:13009:19) at chunk-vendors.js:58322:99 at chunk-vendors.js:58398:6 at Object.ebZT (chunk-vendors.js:58444:2) at __webpack_require__ (index.js:854:30) at fn (index.js:151:20) at Object.a1KO (chunk-vendors.js:56057:37) at __webpack_require__ (index.js:854:30) at fn (index.js:151:20) at eval (main.js:3:1)
复现步骤 [复现问题的步骤]
预期结果 网页可以正常运行
实际结果
Uncaught TypeError: Cannot set properties of undefined (setting 'default') at _regeneratorRuntime (chunk-vendors.js:13009:19) at chunk-vendors.js:58322:99 at chunk-vendors.js:58398:6 at Object.ebZT (chunk-vendors.js:58444:2) at __webpack_require__ (index.js:854:30) at fn (index.js:151:20) at Object.a1KO (chunk-vendors.js:56057:37) at __webpack_require__ (index.js:854:30) at fn (index.js:151:20) at eval (main.js:3:1)
系统信息:
Environment Info:
System: OS: macOS 11.6 CPU: (8) arm64 Apple M1 Binaries: Node: 16.13.0 - /usr/local/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 8.3.0 - /usr/local/bin/npm Browsers: Chrome: 101.0.4951.64 Firefox: 100.0.2 Safari: 14.1.2 npmPackages: @dcloudio/types: ^2.6.7 => 2.6.10 @dcloudio/uni-app-plus: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-app-plus-nvue: 0.0.1 @dcloudio/uni-app-plus-nvue-v8: 0.0.1 @dcloudio/uni-automator: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-cli-i18n: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-cli-shared: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-h5: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-helper-json: * => 1.0.13 @dcloudio/uni-i18n: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-migration: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-mp-360: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-mp-alipay: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-mp-baidu: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-mp-jd: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-mp-kuaishou: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-mp-lark: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-mp-qq: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-mp-toutiao: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-mp-vue: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-mp-weixin: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-mp-xhs: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-quickapp-native: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-quickapp-webview: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-stat: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/uni-template-compiler: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/vue-cli-plugin-hbuilderx: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/vue-cli-plugin-uni: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/vue-cli-plugin-uni-optimize: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/webpack-uni-mp-loader: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @dcloudio/webpack-uni-nvue-loader: 0.0.1 @dcloudio/webpack-uni-pages-loader: ^2.0.1-34720220422002 => 2.0.1-34720220422002 @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.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.15 => 4.5.17 @vue/cli-plugin-router: 4.5.17 @vue/cli-plugin-vuex: 4.5.17 @vue/cli-service: ~4.5.15 => 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/shared: ^3.0.0 => 3.2.36 @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: 4.5.15 `