{"record":{"id":"78f8bf490d7f14c1","repo":"medusajs/medusa","slug":"invalid-module-name-name-module-names-must-b","errorCode":null,"errorMessage":"Invalid module name \"${name}\". Module names must be alpha numeric and may contain an underscore","messagePattern":"Invalid module name \"(.+?)\"\\. Module names must be alpha numeric and may contain an underscore","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/utils/src/common/validate-module-name.ts","lineNumber":21,"sourceCode":" * a lot of code, types under the hood using the module name we\n * have ensure that each module name is variable safe.\n *\n * Ofcourse, we can transform the module name to a variable safe value,\n * but that might result into naming conflicts. For example: There are\n * two module named as\n *\n * - sanity-products\n * - sanity_products\n *\n * After transforming them, they will endup with the same output. This is\n * a very simple example, but cases like these will lead to naming\n * conflicts, so its better to use the names as it is and restrict\n * them to be variable safe\n */\nconst RE = /^[a-zA-Z_][0-9a-zA-Z_]*$/\nexport function validateModuleName(name: string) {\n  if (!RE.test(name)) {\n    throw new Error(\n      `Invalid module name \"${name}\". Module names must be alpha numeric and may contain an underscore`\n    )\n  }\n}\n","sourceCodeStart":3,"sourceCodeEnd":26,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/utils/src/common/validate-module-name.ts#L3-L26","documentation":"During type generation (gml/medusa dev typegen), module names are turned into TypeScript identifiers, so they must match /^[a-zA-Z_][0-9a-zA-Z_]*$/. Names with dashes, dots, spaces, or leading digits throw.","triggerScenarios":"Naming a custom module declaration key like \"my-module\" or \"1catalog\" then running `medusa db generate`/typegen; the key would produce an invalid generated variable name.","commonSituations":"Copying npm-style kebab-case package names as module keys, or renaming modules without checking identifier rules.","solutions":["Rename the module key to alphanumeric/underscore, e.g. myModule or my_module","Keep the npm package kebab-case in `resolve` but set `key` to an identifier-safe name"],"exampleFix":"// before\nmodules: [{ resolve: \"./src/modules/my-blog\", key: \"my-blog\" }]\n// after\nmodules: [{ resolve: \"./src/modules/my-blog\", key: \"myBlog\" }]","handlingStrategy":"validation","validationCode":"if (!/^[a-zA-Z_][0-9a-zA-Z_]*$/.test(moduleKey)) throw new Error('module key must be identifier-safe')","typeGuard":"const isIdentifierSafe = (s: string): boolean => /^[a-zA-Z_][0-9a-zA-Z_]*$/.test(s)","tryCatchPattern":null,"preventionTips":["Use camelCase module keys even when the package name is kebab-case","Test typegen in CI"],"tags":["modules","codegen","naming","validation"],"backgroundTag":"invalid-identifier-name","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}