How to add PWA support in Angular project? #7183
Replies: 6 comments 13 replies
-
If you created the workspace with the Angular preset, that command still works the same. If you created an empty workspace and added an Angular application you can install the package and run the schematic manually. npm install @angular/pwa --save-dev
nx g @angular/pwa:ng-add --project *project-name* |
Beta Was this translation helpful? Give feedback.
-
Hi guys, I am trying to apply pwa but I got the errro below. Does someone have any idea how to make this work? I have NX version 14.5.10
|
Beta Was this translation helpful? Give feedback.
-
#10678 (comment) solved the issue for me... |
Beta Was this translation helpful? Give feedback.
-
I was able to resolve the issue by creating an app.module file (which was missing in my full standalone app): @NgModule({})
export class AppModule { } Then I ran the following command: Next, I moved the ServiceWorkerModule import inside importProvidersFrom in the main.ts file and deleted app.module file. ...
bootstrapApplication(AppComponent, {
providers: [
importProvidersFrom(
ServiceWorkerModule.register('ngsw-worker.js', {
enabled: true,
registrationStrategy: 'registerWhenStable:30000'
}),
),
],
}).catch((err) => console.error(err)); Finally, after restarting the serve, everything was working as expected. I hope this solution works for you as well. |
Beta Was this translation helpful? Give feedback.
-
ng-add with peer-legacy-deps. Adding @angular/pwa to mono repo throws up error
⠦ Installing packages (npm)...npm ERR! code ERESOLVE npm ERR! A complete log of this run can be found in: |
Beta Was this translation helpful? Give feedback.
-
Please add support for |
Beta Was this translation helpful? Give feedback.
-
I have created plain Nx workspace with an Angular app in it. How can I add PWA support to this project? I remember without Nx in plain Angular project we can add like this:
ng add @angular/pwa --project *project-name*
Any ways / commands we have in Nx to achieve this?
Beta Was this translation helpful? Give feedback.
All reactions