uni-app Error: Cannot find module '@/uni_modules/uni-upgrade-center-app/utils/check-update'

uni-app Error: Cannot find module ‘@/uni_modules/uni-upgrade-center-app/utils/check-update’

操作步骤:

  • HBuilderx --> 运行 --> android

预期结果:

  • 编译不报错 并且拉起自动更新

实际结果:

  • 编译报错

bug描述:

接入 uni-upgrade-center-app
在使用页面调用

import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'

报错

Error: Cannot find module '@/uni_modules/uni-upgrade-center-app/utils/check-update'  

调用checkUpdate 报错

信息
产品分类 uniapp/App
PC开发环境操作系统 Mac
PC开发环境版本号 14.0 (23A344)
HBuilderX类型 正式
HBuilderX版本号 3.95
手机系统 Android
手机系统版本号 Android 9.0
手机厂商 华为
手机机型 华为 P40 pro
页面类型 vue
vue版本 vue2
打包方式 云端
项目创建方式 HBuilderX

Image Image Image

2 回复

把引用 ‘@/uni_modules/uni-upgrade-center-app/utils/check-update’ 注释掉就可以正常运行?


The error message Cannot find module '@/uni_modules/uni-upgrade-center-app/utils/check-update' indicates that your project is unable to locate the specified module in the given path. Here are some steps to troubleshoot and resolve this issue:


1. Verify the Module Path

  • Ensure that the module check-update exists in the specified path: @/uni_modules/uni-upgrade-center-app/utils/.
  • Check for typos in the path or module name.

2. Check the uni_modules Directory

  • Confirm that the uni_modules directory exists in your project root.
  • Ensure that the uni-upgrade-center-app plugin is correctly installed in the uni_modules directory.

3. Reinstall the Plugin

  • If the plugin is missing or corrupted, reinstall it:
    1. Open the uni_modules directory.
    2. Delete the uni-upgrade-center-app folder (if it exists).
    3. Reinstall the plugin via the HBuilderX plugin market or manually.

4. Check for Aliases

  • The @ symbol is typically an alias for the src directory in uni-app projects. Ensure that your project configuration (e.g., vue.config.js or vite.config.js) correctly resolves the @ alias.

5. Update Dependencies

  • If the plugin is outdated, it might cause compatibility issues. Update the plugin to the latest version.

6. Clear Cache and Rebuild

  • Clear the project cache and rebuild:
    1. In HBuilderX, go to Project > Clear Project Cache.
    2. Rebuild the project.

7. Check for Missing Files

  • If the check-update file is missing, it might have been accidentally deleted. Restore it from a backup or reinstall the plugin.

8. Debug the Code

  • If the issue persists, debug the code where the module is imported. Ensure that the import statement is correct:
    import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
回到顶部
AI 助手
你好,我是IT营的 AI 助手
您可以尝试点击下方的快捷入口开启体验!