[英]Angular 2 + CLI : Error in Maximum call stack size exceeded
I have a problem with my Ng2 project for 3 - 4 days.我的 Ng2 项目有 3-4 天的问题。
I run ng serv / ng test or ng build and i have: "ERROR in Maximum call stack size exceeded"我运行 ng serv / ng test 或 ng build 我有:“超出最大调用堆栈大小错误”
After "ng serve"在“ng服务”之后
$ ng serve
** NG Live Development Server is running on http://localhost:4200 **
Hash: a73c4ecdb8222366629e
Time: 16536ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 405 kB {5} [initial] [rendered]
chunk {1} main.bundle.js, main.bundle.js.map (main) 41.1 kB {4} [initial] [rendered]
chunk {2} styles.bundle.js, styles.bundle.js.map (styles) 149 kB {5} [initial] [rendered]
chunk {3} scripts.bundle.js, scripts.bundle.js.map (scripts) 244 kB {5} [initial] [rendered]
chunk {4} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.75 MB [initial] [rendered]
chunk {5} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
ERROR in Maximum call stack size exceeded
webpack: Failed to compile.
After I save one time and all is alright:在我保存一次之后一切正常:
$ ng serve
** NG Live Development Server is running on http://localhost:4200 **
Hash: a73c4ecdb8222366629e
Time: 16536ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 405 kB {5} [initial] [rendered]
chunk {1} main.bundle.js, main.bundle.js.map (main) 41.1 kB {4} [initial] [rendered]
chunk {2} styles.bundle.js, styles.bundle.js.map (styles) 149 kB {5} [initial] [rendered]
chunk {3} scripts.bundle.js, scripts.bundle.js.map (scripts) 244 kB {5} [initial] [rendered]
chunk {4} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.75 MB [initial] [rendered]
chunk {5} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
ERROR in Maximum call stack size exceeded
webpack: Failed to compile.
webpack: Compiling...
Hash: 02fd7618c3e2de3db52e
Time: 9915ms
chunk {0} 0.chunk.js, 0.chunk.js.map 926 kB {1} {2} {3} {5} [rendered]
chunk {1} 1.chunk.js, 1.chunk.js.map 397 kB {0} {2} {3} {5} [rendered]
chunk {2} 2.chunk.js, 2.chunk.js.map 33.1 kB {0} {1} {3} {5} [rendered]
chunk {3} 3.chunk.js, 3.chunk.js.map 2.96 kB {0} {1} {2} {5} [rendered]
chunk {4} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 405 kB {9} [initial] [rendered]
chunk {5} main.bundle.js, main.bundle.js.map (main) 41.1 kB {8} [initial] [rendered]
chunk {6} styles.bundle.js, styles.bundle.js.map (styles) 149 kB {9} [initial] [rendered]
chunk {7} scripts.bundle.js, scripts.bundle.js.map (scripts) 244 kB {9} [initial] [rendered]
chunk {8} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.75 MB [initial] [rendered]
chunk {9} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
webpack: Compiled successfully.
And for "ng test" is same.而对于“ng test”也是一样的。
Any idea to resolve this?有什么办法解决这个问题吗?
I met with the same error.我遇到了同样的错误。 Solved by deleting unnecessary imports .
通过删除不必要的导入解决。
Cause of this error you have circular module dependency problem.此错误的原因是您有循环模块依赖问题。
For example:
例如:
'A' module imports (dependent to) 'B' module
“A”模块导入(依赖于)“B”模块
'B' module imports (dependent to) 'A' module
“B”模块导入(依赖于)“A”模块
I suggest you to build a common module that other modules should import the common module.我建议你构建一个公共模块,其他模块应该导入公共模块。
If you have unnecessary imports delete unnecessary imports .如果您有不必要的导入,请删除不必要的导入。
The best way i found to debug this is :我发现调试这个的最好方法是:
ng serve --aot
It will exit building if any error is found with an understandable error.如果发现任何带有可理解错误的错误,它将退出构建。
If you getter (or a method) returns itself you will get circular reference resulting in Maximum call stack size exceeded exception.如果您的 getter(或方法)返回自身,您将获得循环引用,从而导致超出最大调用堆栈大小异常。 Ex.
前任。
public get test(): any {
return test;
} }
Review your code for that.为此检查您的代码。
在我的情况下,当尝试调用它自己的组件的选择器时会发生这种情况(循环依赖的种类)。
I have faced this issue.I forgot to import my feature router module to feature module, so i got the above error.我遇到了这个问题。我忘记将我的功能路由器模块导入功能模块,所以我收到了上述错误。 hope it helps others..
希望它可以帮助别人..
Deleting the node_modules
folder, then running npm install
and ng serve
again did the trick for me.删除
node_modules
文件夹,然后再次运行npm install
和ng serve
对我有用。
Got the tip from here: https://github.com/angular/angular-cli/issues/17106从这里得到提示: https ://github.com/angular/angular-cli/issues/17106
In my case I put a component in the wrong sub-module.就我而言,我将一个组件放在错误的子模块中。 Kind of a cryptic error for a misplaced componnet.
对于放错位置的组件来说,这是一种神秘的错误。 For example:
例如:
src
|-account
|-account.modue.ts
|-admin
|-admin.module.ts
|-users
|-user-maintenance.component.ts
account.module.ts
...
@NgModule({
declarations: [
UserMaintenanceComponent // this should be in admin.module.ts
...
I got this error due to circular dependency of modules import.由于模块导入的循环依赖,我得到了这个错误。
A -> B, B -> A, A -> B, B -> A,
I have solved this just by removing A from B and added to app.module.ts.我只是通过从 B 中删除 A 并添加到 app.module.ts 来解决这个问题。
When I have got an当我有一个
Error in maximum call stack exceeded
超出最大调用堆栈错误
Resolved using following command:使用以下命令解决:
ng build --prod --base-href "PATH OF SERVER" --aot=false --build-optimizer=false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.