比较复杂的项目中,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
————————————————
标签:node,old,space,max,ng,size 来源: https://www.cnblogs.com/airen123/p/12401049.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。