You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ember v3.28升级ember-auto-import至v2后,运行时Loader.js报MissingModule错误求助

解决ember-auto-import 2.x + Webpack 5升级后的MissingModule错误

问题根源

ember-auto-import 2.x 切换到Webpack 5后,默认不再自动打包第三方Ember插件的npm依赖(比如ember-rollbar-client依赖的lodash.merge),而1.x版本会自动处理这类嵌套依赖。

修复方案

1. 显式声明需打包的依赖

修改ember-cli-build.js,在autoImport配置的include数组中指定缺失的npm包:

module.exports = function(defaults) {
  let app = new EmberApp(defaults, {
    autoImport: {
      include: ['lodash.merge']
    }
  });

  return app.toTree();
};

若有多个缺失依赖,全部添加到include数组即可。

2. 排查插件兼容性

ember-rollbar-client@0.9.0是较老版本,可能未适配Webpack 5:

  • 查看插件仓库是否有适配新版本的更新或issue
  • 尝试升级插件到最新版本(若存在),新版本通常会修复依赖打包问题

3. 清理缓存重新构建

执行以下命令清除缓存,避免旧缓存干扰:

rm -rf node_modules dist tmp
npm install
ember serve

补充说明

若多个第三方插件都存在类似问题,可尝试autoImport的watchDependencies配置自动监听插件依赖变化,但显式声明include对固定版本插件来说更可靠。

内容的提问来源于stack exchange,提问作者David Bader

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 18:31:01