// utils/http.js
class Http{
async init(){}
}
export default new Http()
// app.vue
import http from '@/utils/http'
- 发布:2022-05-24 14:07
- 更新:2022-06-21 11:26
- 阅读:747
产品分类: uniapp/H5
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 12.3.1
浏览器平台: Chrome
浏览器版本: 101.0.4951.64
项目创建方式: CLI
CLI版本号: 2.0.1-34720220422002
示例代码:
操作步骤:
vue create -p dcloudio/uni-preset-vue my-project
cd my-project
vue create -p dcloudio/uni-preset-vue my-project
cd my-project
预期结果:
不知道是不是1.18.0版本缺少哪个自动引入的插件
不知道是不是1.18.0版本缺少哪个自动引入的插件
实际结果:
chunk-vendors.js:12075 Uncaught TypeError: Cannot set properties of undefined (setting 'default')
at _regeneratorRuntime (chunk-vendors.js:12075:19)
at eval (7Qib:37:98)
at eval (7Qib:54:6)
at eval (7Qib:57:2)
at Object.7Qib (index.js:1040:1)
at webpack_require (index.js:854:30)
at fn (index.js:151:20)
at eval (http.js:1:1)
at Object.dRp0 (index.js:1386:1)
at webpack_require (index.js:854:30)
_regeneratorRuntime @ chunk-vendors.js:12075
eval @ 7Qib:37
eval @ 7Qib:54
eval @ 7Qib:57
7Qib @ index.js:1040
webpack_require @ index.js:854
fn @ index.js:151
eval @ http.js:1
dRp0 @ index.js:1386
webpack_require @ index.js:854
fn @ index.js:151
eval @ App.vue:2
O07N @ index.js:1130
webpack_require @ index.js:854
fn @ index.js:151
eval @ null:1
I77X @ index.js:1118
webpack_require @ index.js:854
fn @ index.js:151
eval @ null:1
Pf3K @ index.js:1142
webpack_require @ index.js:854
fn @ index.js:151
eval @ main.js:2
Vtdi @ index.js:1154
webpack_require @ index.js:854
fn @ index.js:151
1 @ index.js:1009
__webpack_require__ @ index.js:854
checkDeferredModules @ index.js:46
Show 2 more frames
chunk-vendors.js:12075 Uncaught TypeError: Cannot set properties of undefined (setting 'default')
at _regeneratorRuntime (chunk-vendors.js:12075:19)
at eval (7Qib:37:98)
at eval (7Qib:54:6)
at eval (7Qib:57:2)
at Object.7Qib (index.js:1040:1)
at webpack_require (index.js:854:30)
at fn (index.js:151:20)
at eval (http.js:1:1)
at Object.dRp0 (index.js:1386:1)
at webpack_require (index.js:854:30)
_regeneratorRuntime @ chunk-vendors.js:12075
eval @ 7Qib:37
eval @ 7Qib:54
eval @ 7Qib:57
7Qib @ index.js:1040
webpack_require @ index.js:854
fn @ index.js:151
eval @ http.js:1
dRp0 @ index.js:1386
webpack_require @ index.js:854
fn @ index.js:151
eval @ App.vue:2
O07N @ index.js:1130
webpack_require @ index.js:854
fn @ index.js:151
eval @ null:1
I77X @ index.js:1118
webpack_require @ index.js:854
fn @ index.js:151
eval @ null:1
Pf3K @ index.js:1142
webpack_require @ index.js:854
fn @ index.js:151
eval @ main.js:2
Vtdi @ index.js:1154
webpack_require @ index.js:854
fn @ index.js:151
1 @ index.js:1009
__webpack_require__ @ index.js:854
checkDeferredModules @ index.js:46
Show 2 more frames
bug描述:
一周前创建了新项目, utils/http.js文件内容如下所示:
class Http{
async init(){}
}
export default new Http()
项目开发及部署都正常, 今天删除了yarn.lock文件 重新 yarn install, 就报错了, 项目无任何改动.
经过测试, 有两种解决方案:
- async函数改为sync函数,
- 模块暴露方式改为 commonjs方式即可
但是这两种方式,都引起项目较大改动,
经过比对yarn.lock文件, 发现4天前@babel内发布了一次1.18.0更新, 更新了包括@babel/core @balel/runtime在内的大部分npm包, 移除yarn.lock文件重新安装后, /node_module内安装了@babel/*@1.18.0版本, 是导致项目报错的主要原因, 但是没找到解决方案
5 个回复
i***@smartwell.cn
我也遇到了同样的问题。
9***@qq.com - 哈哈
我也是
Anet
我也是
shunyue - 00后
解决方法:
https://blog.csdn.net/qq_41614928/article/details/125387594
shunyue - 00后
解决方法