GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||
GeezerVison is showing github.com — ng add @angular/pwa cannot find AppModule if imported through index.ts · Issue #11499 · angular/angular-cli Open Labels area: @angular/pwafreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity3: brokentype: bug/fix Milestone DescriptionBug Report or Feature Request (mark with an
|
| export function findBootstrapModulePath(host: Tree, mainPath: string): string { |
This method is called by updateAppModule from
| const modulePath = getAppModulePath(host, mainPath); |
The failure occurs when trying to update the content of a file which does not exists. Checking the file exists and displaying a better message would also help.
The issue was encountered when attempting to add PWA to our NGXP Seed web side.
$ git clone https://github.com/Monogramm/ngxp-seed.git
$ git checkout develop
$ ng add @angular/pwa --project web
Since we managed to find out the root cause, the workaround of using the complete path will be used for now.
I had similar problem. In my case I'm using tsconfig path mapping and reference AppModule in main.ts with that reference:
import { AppModule } from '@app/app.module';
I get the same type of error: Could not read file (/src/@app/app.module.ts).
Changing back only that reference to import { AppModule } from './app/app.module'; in main.ts results execution of ng add @angular/pwa as expected
We went for the same solution of import { AppModule } from './app/app.module';.
Knowing this workaround makes the issue less critical but it's still a bit weird to be forced to do this just to add a component 😉
it also doesn't find it if you have alias for imports
Is this issue abandoned @kyliau? I faced in 2022. After 2 years this issue still exists 🤒?
You can reproduce the issue in this repo. Just do ng add @angular/material
BTW I hope this issues resolve. @angular-robot