{"record":{"id":"51b7e7b8e27f5e11","repo":"angular/angular-cli","slug":"specified-module-options-module-does-not-exis","errorCode":null,"errorMessage":"Specified module '${options.module}' does not exist.\\nLooked in the following directories:\\n    ${candidatesDirs.join('\\n    ')}","messagePattern":"Specified module '(.+?)' does not exist\\.\\\\nLooked in the following directories:\\\\n    (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/schematics/angular/utility/find-module.ts","lineNumber":74,"sourceCode":"    if (options.moduleExt) {\n      candidateFiles.push(`${moduleBaseName}${options.moduleExt}`);\n    } else {\n      candidateFiles.push(\n        `${moduleBaseName}${MODULE_EXT}`,\n        `${moduleBaseName}${MODULE_EXT_LEGACY}`,\n      );\n    }\n\n    for (const c of candidatesDirs) {\n      for (const sc of candidateFiles) {\n        const scPath = join(c, sc);\n        if (host.exists(scPath) && host.readText(scPath).includes('@NgModule')) {\n          return normalize(scPath);\n        }\n      }\n    }\n\n    throw new Error(\n      `Specified module '${options.module}' does not exist.\\n` +\n        `Looked in the following directories:\\n    ${candidatesDirs.join('\\n    ')}`,\n    );\n  }\n}\n\n/**\n * Function to find the \"closest\" module to a generated file's path.\n */\nexport function findModule(\n  host: Tree,\n  generateDir: string,\n  moduleExt?: string,\n  routingModuleExt?: string,\n): Path {\n  let dir: DirEntry | null = host.getDir('/' + generateDir);\n  let foundRoutingModule = false;\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/schematics/angular/utility/find-module.ts#L56-L92","documentation":"findModuleFromOptions is used when the user explicitly names a module via the `--module` option. After searching the given path and candidate directories for a file containing `@NgModule` matching the given name/path, the schematic throws when no such file exists.","triggerScenarios":"Calling a schematic (component, directive, pipe, module) with `--module path/to/module` or `-m AppModule` where the path is misspelled, relative to the wrong directory, or the module file does not exist under any of the candidate directories.","commonSituations":"Typo in --module flag (e.g. `-m app.module` vs `app.module.ts`); module lives in a different folder than the generated component; path given without extension or with wrong case on case-sensitive filesystems; running from a subdirectory so relative paths resolve differently.","solutions":["Check the directories listed in the error message and correct the --module path, e.g. `ng g c my-comp -m app`.","Pass the path relative to src/app, including the directory: `-m paths/to/shared/shared.module`.","Create the missing NgModule first (`ng g module shared`) or use --skip-import to skip module wiring."],"exampleFix":"// before\nng g c user --module=app.module\n// after\nng g c user --module=app","handlingStrategy":"validation","validationCode":"const modPath = path.resolve('src/app', `${options.module}.module.ts`);\nif (!fs.existsSync(modPath) && !fs.existsSync(path.resolve('src/app', `${options.module}.ts`))) {\n  throw new Error(`--module target not found: ${options.module}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass --module relative to src/app and let the CLI resolve extensions (`-m app`).","Verify the module exists with a quick file check before scripting generation.","Avoid relying on relative paths from nested directories in scripts."],"tags":["angular","schematics","cli","ngmodule"],"backgroundTag":"module-not-found","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}