angular - Generate pages: Error: Specified module 'home/home.module.ts' does not exist.
See original GitHub issueOffending command
ng g module home --module app --route home
Current Behavior
I’m getting an error when generating a page inside an application:
Specified module 'home/home.module.ts' does not exist.
Expected Behavior
Steps to Reproduce
Create the application
npx create-nx-workspace
> pages-test
> angular
> pages-demo
> scss
> No
code pages-test
Create the AppRoutingModule (app-routing.module.ts)
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
const routes: Routes = [];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
Import the AppRoutingModule
in the AppModule
Generate a page
cd apps/pages-demo/src/app
ng g module home --module app --route home
Result:
Error: Specified module 'home/home.module.ts' does not exist.
Looked in the following directories:
/apps/pages-demo/src/app/home/home.module.ts
/apps/pages-demo/src/app/home
/apps/pages-demo/src/app
/apps/pages-demo/src
/apps/pages-demo
/apps
at findModuleFromOptions (C:\repos\pages-test\node_modules\@schematics\angular\utility\find-module.js:48:15)
at C:\repos\pages-test\node_modules\@schematics\angular\component\index.js:109:66
Error: Specified module 'home/home.module.ts' does not exist.
/apps/pages-demo/src/app/home/home.module.ts
/apps/pages-demo/src/app/home
/apps/pages-demo/src/app
/apps/pages-demo/src
/apps/pages-demo
/apps
at findModuleFromOptions (C:\repos\pages-test\node_modules\@schematics\angular\utility\find-module.js:48:15)
at C:\repos\pages-test\node_modules\@schematics\angular\component\index.js:109:66
Specified module 'home/home.module.ts' does not exist.
Looked in the following directories:
/apps/pages-demo/src/app/home/home.module.ts
/apps/pages-demo/src/app/home
/apps/pages-demo/src/app
/apps/pages-demo/src
/apps/pages-demo
/apps
Environment
- NX: 14.0.3
Angular CLI: 13.3.3
Node: 16.13.1
Package Manager: npm 8.1.2
OS: win32 x64
Angular: undefined
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.1303.3 (cli-only)
@angular-devkit/core 13.2.3
@angular-devkit/schematics 13.2.3
@schematics/angular 13.2.3
Debug NX schematics
Issue Analytics
- State:
- Created a year ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Specified module does not exist Angular 6 - Stack Overflow
Below code works on latest CLI version. ng generate component messages --module app.core.module. It doesn't requires .ts.
Read more >Create a feature component - Angular
Keeping all features in one component as the application grows won't be maintainable. This tutorial splits up large components into smaller subcomponents, ...
Read more >TypeScript configuration - Angular
When the noImplicitAny flag is true and the TypeScript compiler cannot infer the type, it still generates the JavaScript files, but it also...
Read more >Server-side rendering (SSR) with Angular Universal
A Node.js Express web server compiles HTML pages with Universal based on client requests. To create the server-side application module, app.server.module ...
Read more >Angular package format
Instead of "default" , "module" selects the format both for Node as well as any tooling not configured to use a specific key....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@PieterjanDeClippel the fix was released in v14.1.0.
@PieterjanDeClippel thanks for reporting this!
I haven’t been able to reproduce this on macOS, I’m guessing this is a Windows issue with paths. The schematic for generating a module comes from the
@schematics/angular
package. Our@nrwl/angular
package just extends the schematic collection from that one and therefore, all schematics from that package that we don’t overwrite are executed from there. From the stack trace you shared, you can see the error being thrown atC:\repos\pages-test\node_modules\@schematics\angular\component\index.js:109:66
.I’m trying to set up a Windows VM here to troubleshoot this, but I’ve been having issues with it. It does seem to be an issue in the Angular CLI repo rather than an Nx issue given we don’t own that schematic, but I’ll keep this open to get to the bottom of it.