node内存配置(--max-old-space-size)
比較復(fù)雜的項(xiàng)目中,angular2編譯的時(shí)候?qū)PU和內(nèi)存需求都會(huì)變大。項(xiàng)目中,使用angular-cli@beta28-3編譯。需要內(nèi)存2-3G。node本身,或者說v8本身有一個(gè)默認(rèn)配置: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.
所以我們需要配置一下運(yùn)行內(nèi)存。
I’m on OS X EICapitan(10.11.6) and am running node v6.9.1.My machine has 8GB of RAM.
windows很容易就設(shè)置:
cd C:\Users\Administrator\AppData\Roaming\npm
修改ng.cmd,追加–max_old_space_size=4096 避免aot時(shí)內(nèi)存溢出
#!/bin/sh basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")case `uname` in*CYGWIN*) basedir=`cygpath -w "$basedir"`;; esacif [ -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 $retMac設(shè)置:
路徑:/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感謝您看到了這里,這里是結(jié)尾。如果對(duì)您有幫助,我深感欣慰。自己給自己做廣告,不犯法吧?歡迎關(guān)注WeChat公眾號(hào)
**微信公眾號(hào): 耐撕程序員
有資源
有想法
有技術(shù)貼
隨手掃一掃
不吃虧不上當(dāng)
大家一起天天向上
歡迎掃碼關(guān)注相互交流**
總結(jié)
以上是生活随笔為你收集整理的node内存配置(--max-old-space-size)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第五人格印记类型有几种 《第五人格》官方
- 下一篇: 中国联通怎么查话费(《中国》第一季)