angularprogressive-web-appsstack-size

Maximum call stack size exceeded when adding PWA in Angular


I am trying to install service worker in my application but it showing following error after executing following command.

ng add @angular/pwa --project ServiceWorkerdemo

ng add @angular/pwa --project ServiceWorkerdemo
Installing packages for tooling via npm.
npm WARN rollback Rolling back node-pre-gyp@0.10.0 failed (this is probably harmless): EPERM: operation not permitted, lstat 'path\ServiceWorkerdemo\node_modules\fsevents\node_modules'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @angular/pwa@0.11.3
updated 1 package and audited 47713 packages in 25.858s
found 0 vulnerabilities

Installed packages for tooling via npm.
**Maximum call stack size exceeded**

it showing Maximum call stack size exceeded error message.

Even though I clear cache still it showing same error again.

    >npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.

**path\ServiceWorkerdemo>ng add @angular/pwa --project ServiceWorkerdemo
Installing packages for tooling via npm.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @angular/pwa@0.11.3
updated 1 package and audited 47713 packages in 26.054s
found 0 vulnerabilities

Installed packages for tooling via npm.
Maximum call stack size exceeded

enter image description here

Instead of marking as duplicate kindly suggest me an answer, I have already tried clear cache option but still showing an error message. You can see in Image also.

After deleting node Package. enter image description here

Thanks in advance.


Solution

  • Unless you are using Angular 7 or higher, you need to execute something like

    ng add @angular/pwa@v6-lts --project ...

    to ensure that the correct version of the module that works with your Angular version is installed.

    (Also see https://github.com/angular/angular-cli/issues/12914)

    I had the exact same error you have (Angular 6.1), and was able to solve it successfully in this way.