uni-app 关于 @dcloudio/vue-cli-plugin-uni 更新最新版本后 error-reporting.js 报错
uni-app 关于 @dcloudio/vue-cli-plugin-uni 更新最新版本后 error-reporting.js 报错
开发环境 | 版本号 | 项目创建方式 |
---|---|---|
Mac | 10.15.4 (19E287) | CLI |
操作步骤:
依赖 “@dcloudio/vue-cli-plugin-hbuilderx”: “^2.0.0-31820210406002”, “@dcloudio/vue-cli-plugin-uni”: “^2.0.0-31820210406002”,
## 预期结果:
更新完毕编译报错
实际结果:
更新完毕编译报错
## bug描述:
更新最新的 [@dcloudio](/user/dcloudio)/vue-cli-plugin-uni 版本后,编译打包都抛异常。
更新的库地址:https://registry.npm.taobao.org/[@dcloudio](/user/dcloudio)/vue-cli-plugin-uni/download/[@dcloudio](/user/dcloudio)/vue-cli-plugin-uni-2.0.0-31820210406002.tgz
抛异常: /xxxxxx/node_modules/[@dcloudio](/user/dcloudio)/vue-cli-plugin-uni/lib/error-reporting.js:45
err = err.replace(this._UNI_INPUT_DIR_REG, 'UNI_INPUT_DIR')
^
TypeError: err.replace is not a function
at ErrorReport.report (/xxxxxxx/node_modules/[@dcloudio](/user/dcloudio)/vue-cli-plugin-uni/lib/error-reporting.js:45:15)
at report (/xxxxxxx/node_modules/[@dcloudio](/user/dcloudio)/vue-cli-plugin-uni/lib/error-reporting.js:144:24)
at process.on.on.err (/xxxxxx/node_modules/[@dcloudio](/user/dcloudio)/vue-cli-plugin-uni/lib/error-reporting.js:154:42)
at process.emit (events.js:182:13)
at process._fatalException (internal/bootstrap/node.js:494:27)
更多关于uni-app 关于 @dcloudio/vue-cli-plugin-uni 更新最新版本后 error-reporting.js 报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html
同上
更多关于uni-app 关于 @dcloudio/vue-cli-plugin-uni 更新最新版本后 error-reporting.js 报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html
同上
实际测试,@dcloudio/uni-h5 依赖不可删除,否则会有该问题
因为我这边只开发app相关,所以小程序相关依赖我手动删除了。这里贴一下我的 package.json 配置
测试时间 2021-06-03
{
“name”: “demo”,
“version”: “0.1.0”,
“private”: true,
“scripts”: {
“build:app-plus”: “cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build”,
“dev:app-plus”: “cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build --watch”,
“info”: “node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.js”,
“test:android”: “cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=android jest -i”,
“test:ios”: “cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=ios jest -i”
},
“dependencies”: {
“@dcloudio/uni-app-plus”: “^2.0.0-31920210514002”,
“@dcloudio/uni-h5”: “^2.0.0-31920210514002”,
“@dcloudio/uni-helper-json”: “",
“@dcloudio/uni-i18n”: “^2.0.0-31920210514002”,
“@dcloudio/uni-stat”: “^2.0.0-31920210514002”,
“@vue/shared”: “^3.0.0”,
“core-js”: “^3.6.5”,
“flyio”: “^0.6.2”,
“regenerator-runtime”: “^0.12.1”,
“vue”: “^2.6.11”,
“vue-class-component”: “^6.3.2”,
“vue-property-decorator”: “^8.0.0”,
“vuex”: “^3.2.0”
},
“devDependencies”: {
“@babel/plugin-syntax-typescript”: “^7.2.0”,
“@babel/runtime”: “~7.12.0”,
“@dcloudio/types”: "”,
“@dcloudio/uni-automator”: “^2.0.0-31920210514002”,
“@dcloudio/uni-cli-shared”: “^2.0.0-31920210514002”,
“@dcloudio/uni-migration”: “^2.0.0-31920210514002”,
“@dcloudio/uni-template-compiler”: “^2.0.0-31920210514002”,
“@dcloudio/vue-cli-plugin-hbuilderx”: “^2.0.0-31920210514002”,
“@dcloudio/vue-cli-plugin-uni”: “^2.0.0-31920210514002”,
“@dcloudio/vue-cli-plugin-uni-optimize”: “^2.0.0-31920210514002”,
“@dcloudio/webpack-uni-mp-loader”: “^2.0.0-31920210514002”,
“@dcloudio/webpack-uni-pages-loader”: “^2.0.0-31920210514002”,
“@vue/cli-plugin-babel”: “~4.5.0”,
“@vue/cli-plugin-typescript”: “",
“@vue/cli-service”: “~4.5.0”,
“babel-plugin-import”: “^1.11.0”,
“cross-env”: “^7.0.2”,
“jest”: “^25.4.0”,
“mini-types”: "”,
“miniprogram-api-typings”: “*”,
“postcss-comment”: “^2.0.0”,
“typescript”: “^3.0.0”,
“vue-template-compiler”: “^2.6.11”
},
“browserslist”: [
“Android >= 4”,
“ios >= 8”
],
“uni-app”: {
“scripts”: {}
}
}
请问解决了吗 我也遇到了这个问题
这个错误是由于 [@dcloudio](/user/dcloudio)/vue-cli-plugin-uni
最新版本中 error-reporting.js
模块在处理错误信息时,传入的 err
参数不是字符串类型导致的。
具体问题出现在第45行:
err = err.replace(this._UNI_INPUT_DIR_REG, 'UNI_INPUT_DIR')
当 err
参数是一个 Error 对象而非字符串时,调用 replace
方法就会抛出 TypeError: err.replace is not a function
。
解决方案:
-
临时回退版本 将
[@dcloudio](/user/dcloudio)/vue-cli-plugin-uni
版本回退到上一个稳定版本:"[@dcloudio](/user/dcloudio)/vue-cli-plugin-uni": "2.0.0-31820210401001"
-
等待官方修复 这是一个明显的代码缺陷,官方会在后续版本中修复。建议关注官方更新日志。
-
手动修复(临时) 在
node_modules/[@dcloudio](/user/dcloudio)/vue-cli-plugin-uni/lib/error-reporting.js
中找到第45行,修改为:err = String(err).replace(this._UNI_INPUT_DIR_REG, 'UNI_INPUT_DIR')