nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.51k stars 2.34k forks source link

External Schematic @nrwl/angular application "Could not find an NgModule" #9060

Closed zjkipping closed 2 years ago

zjkipping commented 2 years ago

Current Behavior

When running externalSchematic('@nrwl/angular', 'app', { name: 'test' }) after migrating to nx 13.8.x I get an error stating "Could not find an NgModule. Use the skip-import option to skip importing in NgModule.".

Running a manual yarn nx generate application test works just fine in the command line...

Expected Behavior

Run the above command and an angular application is created successfully in the /apps directory. This worked fine in our 12.7.x nx versions.

Steps to Reproduce

Create custom generator adding externalSchematic('@nrwl/angular', 'app', { name: 'test' }), to the rules chain.

Failure Logs

✳️  Running Command:  nx workspace-schematic product test
$ C:\code\ui-shell\client\node_modules\.bin\tsc -p C:\code\ui-shell\client\tools\tsconfig.generated.json
√ Enter a prefix for component selectors (2-3 characters): · jhg

√ Which stylesheet format would you like to use? · scss
√ Would you like to configure routing for this application? (y/N) · true
[NX] Angular devkit called `writeWorkspace`, this may have had unintended consequences in angular.json
[NX] Double check angular.json before proceeding
Error: Could not find an NgModule. Use the skip-import option to skip importing in NgModule.
    at findModule (C:\code\ui-shell\client\node_modules\@schematics\angular\utility\find-module.js:81:11)
    at findModuleFromOptions (C:\code\ui-shell\client\node_modules\@schematics\angular\utility\find-module.js:26:38)
    at C:\code\ui-shell\client\node_modules\@schematics\angular\component\index.js:105:66
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Error: Could not find an NgModule. Use the skip-import option to skip importing in NgModule.
    at findModule (C:\code\ui-shell\client\node_modules\@schematics\angular\utility\find-module.js:81:11)
    at findModuleFromOptions (C:\code\ui-shell\client\node_modules\@schematics\angular\utility\find-module.js:26:38)
    at C:\code\ui-shell\client\node_modules\@schematics\angular\component\index.js:105:66
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Could not find an NgModule. Use the skip-import option to skip importing in NgModule.
Done in 39.38s.

Environment

Node : 16.13.0
   OS   : win32 x64
   yarn : 1.22.5

   nx : 13.8.3
   @nrwl/angular : 13.8.3
   @nrwl/cli : 13.8.3
   @nrwl/cypress : 13.8.3
   @nrwl/detox : undefined
   @nrwl/devkit : 13.8.3
   @nrwl/eslint-plugin-nx : 13.8.3
   @nrwl/express : undefined
   @nrwl/jest : 13.8.3
   @nrwl/js : 13.8.3
   @nrwl/linter : 13.8.3
   @nrwl/nest : undefined
   @nrwl/next : undefined
   @nrwl/node : undefined
   @nrwl/nx-cloud : undefined
   @nrwl/react : 13.8.3
   @nrwl/react-native : undefined
   @nrwl/schematics : undefined
   @nrwl/storybook : 13.8.3
   @nrwl/tao : 13.8.3
   @nrwl/web : 13.8.3
   @nrwl/workspace : 13.8.3
   typescript : 4.5.5
   rxjs : 6.5.5
   ---------------------------------------
   Community plugins:
         @angular/animations: 13.2.3
         @angular/cdk: 13.2.3
         @angular/common: 13.2.3
         @angular/compiler: 13.2.3
         @angular/core: 13.2.3
         @angular/forms: 13.2.3
         @angular/localize: 13.2.3
         @angular/material: 13.2.3
         @angular/platform-browser: 13.2.3
         @angular/platform-browser-dynamic: 13.2.3
         @angular/router: 13.2.3
         @ngrx/effects: 13.0.2
         @ngrx/router-store: 13.0.2
         @ngrx/store: 13.0.2
         @ngrx/store-devtools: 13.0.2
         @angular-devkit/build-angular: 13.2.4
         @angular/cli: 13.2.4
         @angular/compiler-cli: 13.2.3
         @angular/language-service: 13.2.3
         @compodoc/compodoc: 1.1.18
         @storybook/angular: 6.4.19
zjkipping commented 2 years ago

Seems like a duplicate of #8253.

leosvelperez commented 2 years ago

Closing as duplicate. Follow #8253 for updates.

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.