我正在尝试在应用程序中安装Service Worker,但显示 执行以下命令后出现以下错误。
ng添加@ 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**
它显示已超过最大呼叫堆栈大小错误消息。
即使我清除了缓存,它仍然再次显示相同的错误。
>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
我没有将其标记为重复项,而是建议我一个答案 已经尝试清除缓存选项,但仍显示错误消息。 您也可以在图片中看到。
谢谢。
答案 0 :(得分:1)
除非您使用的是Angular 7或更高版本,否则需要执行类似的操作
ng添加@ angular / pwa @ v6-lts --project ...
确保安装了与Angular版本兼容的模块的正确版本。
(另请参见https://github.com/angular/angular-cli/issues/12914)
我遇到了与您完全相同的错误(Angular 6.1),并且能够以这种方式成功解决它。
答案 1 :(得分:0)
您可以检查此SO post的解决方案,其中指出此错误是由一个函数调用另一个函数等引起的,直到达到调用堆栈限制为止。这称为函数的递归循环。
要对其进行修复,请确保您的递归函数具有可以满足的基本情况:
(function a(x) {
// The following condition
// is the base case.
if ( ! x) {
return;
}
a(--x);
})(10);
您可以检查Chrome开发工具的资源标签。
答案 2 :(得分:0)
我遇到了同样的问题。我可以通过指定以前的稳定版本来使其工作:
ng添加@ angular / pwa @ 0.8.7 --project my-project-name