build:aot:prod 打包出錯 node內存配置(--max-old-space-size)


比較復雜的項目中,angular2編譯的時候對CPU和內存需求都會變大。項目中,使用angular-cli@beta28-3編譯。需要內存2-3G。node本身,或者說v8本身有一個默認配置:Currently, by default v8 has a memory limit of 512mb on 32-bit systems, and 1gb on 64-bit systems. The limit can be raised by setting --max-old-space-size to a maximum of ~1gb (32-bit) and ~1.7gb (64-bit), but it is recommended that you split your single process into several workers if you are hitting memory limits.
所以我們需要配置一下運行內存。

I’m on OS X EICapitan(10.11.6) and am running node v6.9.1.My machine has 8GB of RAM.

方法1.    修改打包配置,在編譯器搜索6096找到package.json文件    把--max_old_space_size=6096的值修改為--max_old_space_size=4096;

 

 

方法2.    設置windows里的參數:

cd C:\Users\Administrator\AppData\Roaming\npm

修改ng.cmd,追加–max_old_space_size=4096 避免aot時內存溢出

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
"$basedir/node --max-old-space-size=6096 " "$basedir/../angular-cli/bin/ng" "$@"
ret=$?
else
node --max-old-space-size=6096 "$basedir/../angular-cli/bin/ng" "$@"
ret=$?
fi
exit $ret

Mac設置:

路徑:/Users/free/Documents/angular-cli/caibian-ng/caibian-static/node_modules/.bin

文件:ng


#!/usr/bin/env node --max-old-space-size=4096
'use strict';

// Provide a title to the process in `ps`
process.title = 'angular-cli';

require('../lib/bootstrap-local');
require('../packages/angular-cli/bin/ng');
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"ng" 8L, 213C
————————————————


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM