尝试通过以下脚本在package.json中运行构建脚本:
"scripts": {
"build-prod": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build --prod"
}
./node_modules/.bin/ng
而不是 ./node_modules/@angular/cli/bin/ng
。这样,如果路径随时更改,您就可以使用符号链接。 - Shinigami我的团队也遇到了同样的问题,这是我们解决方法:
在构建项目时,不要使用ng build --prod
,而要使用以下命令:
node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod --build-optimizer
在你的package.json文件中添加上述字符串,如下所示,并使用npm run prod
构建即可:
{
"name": "Deva_Application",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"prod": "node --max_old_space_size=64384 ./node_modules/@angular/cli/bin/ng build --prod --build-optimizer --output-hashing=none",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
...
}
如果项目很大,将--max_old_space_size增加到16384至64384。
export NODE_OPTIONS=--max_old_space_size=4096
# Browsers that we support
# Take caution when expanding out this list, as builds will require more ram '--max_old_space_size'
last 2 Chrome versions,
last 2 FireFox versions,
last 2 Edge versions,
last 2 Safari versions
last 2 Opera versions
node --max_old_space_size=4096
- yurzui