1

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.

4

3 回答 3

1

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.

于 2018-12-21T09:45:49.167 回答
0

You can check the solution of this SO post where it says that this error is caused by one function calling another function and so forth, until it hits the call stack limit. This is called recursive loop of function.

In order to fix it, ensure that your recursive function has a base case which is able to be met:

(function a(x) {
    // The following condition 
    // is the base case.
    if ( ! x) {
        return;
    }
    a(--x);
})(10); 

You can check the resources tab of the Chrome Dev Tool.

于 2018-12-14T02:48:14.420 回答
0

I'm having the same issue. I was able to get it to work by specifying the previous stable release:

ng add @angular/pwa@0.8.7 --project my-project-name

于 2019-05-02T05:05:49.417 回答