冉娃娃
冉娃娃
  • 发布:2025-08-08 23:30
  • 更新:2025-08-11 17:20
  • 阅读:46

[已解决]基于hbuilderx unicloud创建的模板项目无法修改成ts类型的文件

分类:HBuilderX

问题背景

使用IDE的hello-unicloud模板,创建了一个vue3的应用
但初始化的入口文件是js文件main.js
想要把它改成main.ts
结果运行到h5环境时就报错

错误内容

23:24:15.953 Compiling...  
23:24:16.443   vite v5.2.8 dev server running at:  
23:24:16.443   - Local:   http://localhost:5173/  
23:24:16.447   - Network: http://192.168.1.94:5173/  
23:24:16.447 Project client compiled successfully. Note You can view front-end run logs separately on the browser console.  
23:24:16.453 Click the debug icon (bug) in the upper right corner of the console to enable breakpoint debugging (Add breakpoints: Double-click the editor line number to add breakpoints)  
23:24:16.453 Web version FAQ reference: https://ask.dcloud.net.cn/article/35232  
23:24:16.454   ready in 784ms.  
23:24:16.703 Failed to load url /main.js (resolved id: /main.js). Does the file exist?  
23:24:17.063 Failed to load url /main.js (resolved id: /main.js). Does the file exist?  
23:24:17.093 Failed to load url /main.js (resolved id: /main.js). Does the file exist?

错误截图

解决方案

不使用hbuilderx内置的项目,用cli初始化项目,然后在hbuilderx中进行云函数调试

2025-08-08 23:30 负责人:无 分享
已邀请:
billkes_bg

billkes_bg - 二壶乱砂丨飒飒作响

尝试修改构建配置,显式指定入口为 main.ts

Failed to load url /main.js (resolved id: /main.js). Does the file exist?

// vue.config.js  
module.exports = {  
    configureWebpack: {  
        entry: './src/main.ts' // 指定 TS 入口  
    }  
}
  • 冉娃娃 (作者)

    感谢回复,试了这个方法还是不行。

    2025-08-11 20:17

要回复问题请先登录注册