{"record":{"id":"c7ddd81e3ddcd2ce","repo":"medusajs/medusa","slug":"unable-to-load-resources-for-module-modulepath","errorCode":null,"errorMessage":"Unable to load resources for module ${modulePath} automagically. ${e.message}","messagePattern":"Unable to load resources for module (.+?) automagically\\. (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/core/modules-sdk/src/loaders/utils/load-internal.ts","lineNumber":690,"sourceCode":"    // if a module service is provided, we generate a joiner config\n    if (moduleService) {\n      generateJoinerConfigIfNecessary({\n        moduleResolution,\n        service: moduleService,\n        models: potentialModels,\n      })\n    }\n\n    return {\n      services: potentialServices,\n      models: mikroOrmModels,\n      repositories: potentialRepositories,\n      loaders: finalLoaders,\n      moduleService,\n      normalizedPath,\n    }\n  } catch (e) {\n    logger.warn(\n      `Unable to load resources for module ${modulePath} automagically. ${e.message}`\n    )\n\n    return {} as ModuleResource\n  }\n}\n\nasync function runLoaders(\n  loaders: Function[] = [],\n  {\n    localContainer,\n    container,\n    logger,\n    resolution,\n    loaderOnly,\n    keyName,\n    providerOptions,\n  }","sourceCodeStart":672,"sourceCodeEnd":708,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/modules-sdk/src/loaders/utils/load-internal.ts#L672-L708","documentation":"loadResources is the modules-sdk's auto-loader that conventionally discovers models, migrations, services, and repositories inside a module directory by scanning subfolders. If any part of that filesystem scan/require throws, the whole module resource set is discarded and an empty ModuleResource is returned with this warning, which usually surfaces later as 'module not found' or resolution errors.","triggerScenarios":"Registering a module via medusa-config.js modules entry whose resolution points to a directory with unexpected structure (no src, unexpected file that throws at import time, case-mismatched folder names), or a module path that cannot be resolved/required.","commonSituations":"Local module development with a wrong `resolve` path; a file inside the module that throws at import (e.g. imports a missing dependency); renaming module folders without updating medusa-config; publishing a module package without its src/services and src/models folders.","solutions":["Check the appended ${e.message} — it names the underlying require/scan failure; fix that first (missing file, bad import, wrong path)","Verify the module's `resolve` in medusa-config.js points to the module root that contains src/services, src/models, src/repositories","Ensure every file in the module's src tree imports cleanly (run the module package's build/tests independently)","For non-standard layouts, export an explicit `resources` property (service, models, etc.) from the module instead of relying on automagic discovery"],"exampleFix":"// before (medusa-config.js)\nmodules: [{ resolve: \"./src/modules/my-module\", options: {} }]\n// error if folder actually is src/modules/myModule\n\n// after\nmodules: [{ resolve: \"./src/modules/myModule\", options: {} }]","handlingStrategy":"try-catch","validationCode":"// before registering\nconst fs = require(\"fs\")\nconst p = path.resolve(modulePath, \"src\", \"services\")\nif (!fs.existsSync(p)) throw new Error(`Module ${modulePath} missing src/services`)","typeGuard":null,"tryCatchPattern":"try {\n  await MedusaModule.migrateUp(moduleKey, moduleConfig)\n} catch (e) {\n  logger.error(`module load failed: ${e.message}`) // warning already swallowed details in e.message\n  throw e\n}","preventionTips":["Validate module resolve paths in medusa-config.js at startup","Keep module folder layout conventional (src/services, src/models)","Import-test each module file in CI so bad imports fail the build"],"tags":["modules-sdk","module-loading","filesystem","config"],"backgroundTag":"module-resolution-failed","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}