{"record":{"id":"f697f32c9a095326","repo":"emberjs/ember.js","slug":"could-not-find-module-name-required-by-refer","errorCode":null,"errorMessage":"Could not find module ${name} required by: ${referrerName}","messagePattern":"Could not find module (.+?) required by: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/loader/lib/index.js","lineNumber":18,"sourceCode":"/* eslint-disable no-var */\n/* eslint-disable-next-line no-unused-vars */\nvar define, require;\n\n(function () {\n  if (typeof globalThis.define === 'function' && typeof globalThis.require === 'function') {\n    define = globalThis.define;\n    require = globalThis.require;\n\n    return;\n  }\n\n  var registry = Object.create(null);\n  var seen = Object.create(null);\n\n  function missingModule(name, referrerName) {\n    if (referrerName) {\n      throw new Error('Could not find module ' + name + ' required by: ' + referrerName);\n    } else {\n      throw new Error('Could not find module ' + name);\n    }\n  }\n\n  function internalRequire(_name, referrerName) {\n    var name = _name;\n    var mod = registry[name];\n\n    if (!mod) {\n      name = name + '/index';\n      mod = registry[name];\n    }\n\n    var exports = seen[name];\n\n    if (exports !== undefined) {\n      return exports;","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/emberjs/ember.js/blob/26f97246a8bf2e28edf26ac3093da2e86c04ffc5/packages/loader/lib/index.js#L1-L36","documentation":"The Ember loader's missingModule throws this when internalRequire cannot resolve a module name in its registry and the caller (referrer) is known. It means a `require('some/module')` or inter-module dependency pointed at a module that was never registered with the loader. The referrer is included so you can see which importing module failed.","triggerScenarios":"internalRequire('foo', 'bar') is called, `registry['foo']` is undefined, and a non-empty referrerName is passed. Typical when a module is required before its defining file is loaded or the module id is misspelled.","commonSituations":"Ember addon or app imports a module that isn't in the build (tree-shaken out, addon not installed, wrong import path); AMD/loader-based environments where a file failed to register; typos in relative import paths after refactors.","solutions":["Verify the module id string matches the file's registered module name exactly (check spelling/casing).","Ensure the defining file is included in the build/imported before the requiring module runs.","Run the build and confirm the addon/package providing the module is installed and listed in dependencies.","Use the referrer in the message to open the importing module and fix the import path."],"exampleFix":"// before\nconst helper = require('my-app/helpers/format-dat');\n// after\nconst helper = require('my-app/helpers/format-date');","handlingStrategy":"try-catch","validationCode":"function isModuleLoaded(name){ try { require(name); return true; } catch(e){ return false; } }\nif (!isModuleLoaded('my-app/helpers/format-date')) { console.error('module not registered'); }","typeGuard":"function hasModule(registry, name) { return typeof registry[name] === 'function'; }","tryCatchPattern":"let mod;\ntry { mod = require('my-app/helpers/format-date'); }\ncatch (e) { if (/^Could not find module/.test(e.message)) { mod = fallbackModule; } else { throw e; } }","preventionTips":["Never hand-write require strings; use the bundler/import system.","Keep import paths in sync when renaming files (use IDE rename).","Run the app build in CI to catch unresolvable modules early.","Install addons as dependencies before importing their modules."],"tags":["module-resolution","loader","amd"],"backgroundTag":"module-not-found","analyzedSha":"26f97246a8bf2e28edf26ac3093da2e86c04ffc5","analyzedAt":"2026-09-01T05:01:28.182Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}