uni-app App升级中心打包报错

uni-app App升级中心打包报错

开发环境 版本号 项目创建方式
Windows w10 HBuilderX

产品分类:uniapp/App

PC开发环境操作系统:Windows

HBuilderX类型:正式

HBuilderX版本号:4.25

手机系统:Android

手机系统版本号:Android 13

手机厂商:华为

手机机型:Magic5

页面类型:vue

vue版本:vue2

打包方式:云端

项目创建方式:HBuilderX

示例代码:

[tsl] ERROR at uni_modules\uni-upgrade-center-app\utils\check-update.ts:192
[HBuilder] 16:57:45.160     TS1005:'}' expected.
[HBuilder] 16:57:45.187 [tsl] ERROR at uni_modules\uni-upgrade-center-app\utils\check-update.ts:3
[HBuilder] 16:57:45.209     TS2307:Cannot find module '@/uni_modules/uts-openSchema' or its corresponding type declarations.
[HBuilder] 16:57:45.233 [tsl] ERROR at uni_modules\uni-upgrade-center-app\utils\check-update.ts:11
[HBuilder] 16:57:45.255     TS2304:Cannot find name 'ComponentPublicInstance'.
[HBuilder] 16:57:45.281 [tsl] ERROR at uni_modules\uni-upgrade-center-app\utils\check-update.ts:11
[HBuilder] 16:57:45.304     TS2355:A function whose declared type is neither 'void' nor 'any' must return a value.
[HBuilder] 16:57:45.333 [tsl] ERROR at uni_modules\uni-upgrade-center-app\utils\check-update.ts:101
[HBuilder] 16:57:45.354     TS2451:Cannot redeclare block-scoped variable 'confirmText'.
[HBuilder] 16:57:45.385 [tsl] ERROR at uni_modules\uni-upgrade-center-app\utils\check-update.ts:104
[HBuilder] 16:57:45.422     TS2451:Cannot redeclare block-scoped variable 'confirmText'.
[HBuilder] 16:57:45.455 [tsl] ERROR at uni_modules\uni-upgrade-center-app\utils\check-update.ts:180
[HBuilder] 16:57:45.488     TS2339:Property 'errMsg' does not exist on type 'InstallApkFail'.
[HBuilder] 16:57:45.514  ERROR  Build failed with errors.

操作步骤:

更新升级中心之后打包报错

预期结果:

不报错

实际结果:

报错

bug描述:

App升级中心打包报错,没用到ts也会报错

更多关于uni-app App升级中心打包报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html

18 回复

本地运行会报错吗?检查一下这个文件里的条件编译,如果还是过不去,可以把 updateUseModal 方法和这个方法相关的逻辑都删除掉试试看

更多关于uni-app App升级中心打包报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html


本地不会,就是打包会报错

删掉check-update.ts这个文件可以正常打包,但是上传新版本,旧版本(上一个删除check-update.ts的版本)没有升级更新弹框

回复 Burger: 这个文件你肯定不能删的,但是你可以删除这个文件里面 updateUseModal 相关的逻辑,试试可以打包吗

回复 DCloud_UNI_LXH: 不行,将ts的updateUseModal的函数删除了也无法打包 [HBuilder] 10:42:35.094 [tsl] ERROR at uni_modules\uni-upgrade-center-app\utils\check-update.ts:83 [HBuilder] 10:42:35.117 TS1005:’}’ expected. [HBuilder] 10:42:35.138 [tsl] ERROR at uni_modules\uni-upgrade-center-app\utils\check-update.ts:3 [HBuilder] 10:42:35.161 TS2307:Cannot find module ‘@/uni_modules/uts-openSchema’ or its corresponding type declarations. [HBuilder] 10:42:35.187 [tsl] ERROR at uni_modules\uni-upgrade-center-app\utils\check-update.ts:11 [HBuilder] 10:42:35.214 TS2304:Cannot find name ‘ComponentPublicInstance’. [HBuilder] 10:42:35.237 [tsl] ERROR at uni_modules\uni-upgrade-center-app\utils\check-update.ts:11 [HBuilder] 10:42:35.261 TS2355:A function whose declared type is neither ‘void’ nor ‘any’ must return a value. [HBuilder] 10:42:35.291 ERROR Build failed with errors.

回复 Burger: 你是 uni1 还是 uni x 打包?你把你报错的这个文件,发出来我看看

回复 DCloud_UNI_LXH: uni1打包的,文件就是check-update.ts,直接从插件市场更新下来的,只删除了updateUseModal这个方法

回复 Burger: 这个文件里面应该有一个 export default 的方法,然后 export default 使用了条件编译,你把 // #ifdef UNI-APP-X 条件编译的部分删除掉,算上条件编译就三行代码,别删多了。然后打包试试看

回复 DCloud_UNI_LXH: 我将 // #ifdef UNI-APP-X export default function (component : ComponentPublicInstance | null = null) : Promise<UniUpgradeCenterResult> { // #endif 这个删掉,还是报错 [tsl] ERROR at uni_modules\uni-upgrade-center-app\utils\check-update.ts:79 [HBuilder] 15:33:12.418 TS1128:Declaration or statement expected. [HBuilder] 15:33:12.444 [tsl] ERROR at uni_modules\uni-upgrade-center-app\utils\check-update.ts:3 [HBuilder] 15:33:12.464 TS2307:Cannot find module ‘@/uni_modules/uts-openSchema’ or its corresponding type declarations. [HBuilder] 15:33:12.489 [tsl] ERROR at uni_modules\uni-upgrade-center-app\utils\check-update.ts:65 [HBuilder] 15:33:12.516 TS2304:Cannot find name ‘component’. [HBuilder] 15:33:12.544 ERROR Build failed with errors.

这个报错应该是你没有下载依赖,去插件市场下载一下 uts-openSchema

有的,重新覆盖之后还是之前的报错,impot引用openSchema那一栏代码提示 已声明“openSchema”,但从未读取其值。

回复 Burger: 那就干掉这个引用

回复 DCloud_UNI_LXH: component?.$callMethod(‘show’, true, uniUpgradeCenterResult)这里的component提示没定义

回复 Burger: 可以把 uni-app-x 的条件编译都去掉。我使用最新版的升级中心 vue2 项目,最新稳定版 HX,打包了几次,都是没有问题的,可以成功打包

回复 DCloud_UNI_LXH: 全部去掉跟删了这个ts文件有啥区别,ts里全是条件编译

回复 DCloud_UNI_LXH: 可以正常打包了,就等之后试试更新弹框的问题还有没有了,之前把ts删掉之后没有更新弹框

回复 Burger:

回复 DCloud_UNI_LXH: 升级中心版本0.8.3,hx版本4.24.2024072208,现在打包不报错了,之前因为把check-update.ts整个删掉,升级版本时没有更新弹窗,下次更新再试试吧

回到顶部