2
由於我的angular-cli應用程序對內存要求越來越高,我在ng build --prod
期間開始經歷節點崩潰。我已經看到了這樣的解決方案:如何在運行構建時爲node.js分配更多內存? (Mac)
node --max_old_space_size=4096 myAwesomeServer.js
,但怎麼可能被應用到ng
命令(ESP ng bundle
。)?
由於我的angular-cli應用程序對內存要求越來越高,我在ng build --prod
期間開始經歷節點崩潰。我已經看到了這樣的解決方案:如何在運行構建時爲node.js分配更多內存? (Mac)
node --max_old_space_size=4096 myAwesomeServer.js
,但怎麼可能被應用到ng
命令(ESP ng bundle
。)?
允許您設置節點的命令行選項,通過環境變量:
NODE_OPTIONS=--max-old-space-size=4096 ng bundle
https://nodejs.org/api/cli.html#cli_node_options_options
還允許你爲什麼你認爲`ng`用來運行NG像
node --max-old-space-size=2048 $(which ng) bundle # not tested by myself
這些參數?它們用於'節點'過程。 'ng'只使用[這些參數](https://github.com/angular/angular-cli/wiki/build#options) – alexmac
NODE_OPTIONS環境變量由節點進程本身讀取。節點進程實際執行'ng'(參見ng的shebang - https://github.com/angular/angular-cli/blob/master/bin/ng - 調用'ng'在當前環境中執行節點,源代碼爲ng '腳本)。 –