我在Windows 10中为angular 4项目进行prod构建时遇到跟随错误:
92% chunk asset optimization
<--- Last few GCs --->
[2608:000002518B1007B0] 578653 ms: Mark-sweep 1400.7 (1534.2) -> 1400.7 (1502.2) MB, 1409.9 / 0.0 ms last resort
[2608:000002518B1007B0] 579952 ms: Mark-sweep 1400.7 (1502.2) -> 1400.7 (1501.2) MB, 1298.6 / 0.0 ms last resort
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0000003DF7DA66A1 <JS Object>
1: DoJoin(aka DoJoin) [native array.js:~97] [pc=0000032E01B053FC](this=000001F775C02311 <undefined>,q=0000010002582251 <JS Array[4]>,r=4,F=000001F775C023B1 <true>,B=000001F775C02471 <String[0]: >,A=000001F775C02421 <false>)
2: Join(aka Join) [native array.js:~122] [pc=0000032E01E5AD22](this=000001F775C02311 <undefined>,q=0000010002582251 <JS Array[4]>,r=4,B=000001F775C02471 <String[0]...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
我尝试过的事情: 编辑webpack.cmd如下(正如其中一篇SO帖子所示),但这没有帮助:
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" --max_old_space_size=8048
"%~dp0\..\webpack\bin\webpack.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node --max_old_space_size=8048
node "%~dp0\..\webpack\bin\webpack.js" %*
)
额外信息
@angular/cli: 1.0.0
node: 7.9.0
os: win32 x64
@angular/animations: 4.1.3
@angular/common: 4.1.3
@angular/compiler: 4.1.3
@angular/core: 4.1.3
@angular/forms: 4.1.3
@angular/http: 4.1.3
@angular/platform-browser: 4.1.3
@angular/platform-browser-dynamic: 4.1.3
@angular/router: 4.1.3
@angular/cli: 1.0.0
@angular/compiler-cli: 4.1.3
在这个问题的所有github和SO页面中,建议为节点分配更多内存,我也这样做了,但没有成功。 我非常需要做一个prod构建,请建议我如何克服这个问题
答案 0 :(得分:2)
我已在max_old_space_size
({1}}内的ng.cmd
文件中更改%AppData%\npm
,它就可以了。
启动ng build --prod --env=prod --base-href .
答案 1 :(得分:0)
要实际增加内存大小,您需要在文件调用时使用标记if (rs.next()){
//need to point to my welcome.jsp page or
RequestDispatcher dispatch = request.getRequestDispatcher("/welcome.jsp");
dispatch.forward(request, response);
} else {
//otherwise reload login page....
request.setAttribute("errorMessage", "Authentication failure!");
response.sendRedirect("/login");
}
。将您的代码更改为:
max_old_space_size
这应该可以解决问题。