gpt4 book ai didi

Angular fatal error : Ineffective mark-compacts near heap limit Allocation failed

转载 作者:行者123 更新时间:2023-12-02 21:29:41 25 4
gpt4 key购买 nike

我使用过 Angular 5
我尝试 ng build --prod
显示此错误:
fatal error :接近堆限制的标记压缩无效分配失败 - JavaScript 堆内存不足

我已阅读 thisthis并更改 package.json 中的 -max_old_space_size 但不会再次构建生产,显示上述错误。
有什么问题?怎么解决呢?是package.json的问题吗

package.json:

{
"name": "asd",
"version": "0.6.2",
"license": "MIT",
"angular-cli": {},
"scripts": {
"build:dev": "./node_modules/.bin/ng build",
"build:prod": "./node_modules/.bin/ng build --prod --aot=false",
"build:aot": "./node_modules/.bin/ng build --prod --aot",
"build:aot2": "node --max_old_space_size=4096 ./node_modules/.bin/ng build --prod --aot",
"build": "npm run build:dev",
"clean:dist": "npm run rimraf -- dist",
"clean:install": "npm set progress=false && npm install",
"clean:start": "npm start",
"clean": "npm cache clean && npm run rimraf -- node_modules doc coverage dist",
"e2e:live": "npm run e2e -- --elementExplorer",
"e2e": "npm run protractor",
"lint": "npm run tslint \"src/**/*.ts\"",
"prebuild:dev": "npm run clean:dist",
"prebuild:prod": "npm run clean:dist",
"preclean:install": "npm run clean",
"preclean:start": "npm run clean",
"protractor": "protractor",
"rimraf": "rimraf",
"server:dev": "./node_modules/.bin/ng serve",
"serve": "npm run server:dev",
"start": "npm run server:dev",
"test": "./node_modules/.bin/ng test",
"tslint": "tslint",
"typedoc": "typedoc",
"ng": "ng",
"pree2e": "webdriver-manager update --standalone false --gecko false"
},
"private": true,
....
}

最佳答案

此时升级 Angular 并不能解决问题(但将来可能会解决)。我也在我的 Windows 机器上通过 Angular 7 和 8 项目获得了它。

看起来您可能需要更新 package.json 中的内存增加。 Here is a link这似乎已经为很多人解决了这个问题,我认为您必须在节点模块中指定 Angular CLI 的路径。

而不是

node --max_old_space_size=4096 ./node_modules/.bin/ng build --prod --aot

尝试

node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build --prod --aot

解决方案中的这条路径看起来正确 back to Angular 4 .

关于 Angular fatal error : Ineffective mark-compacts near heap limit Allocation failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56610005/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com