当前位置: 首页 > 知识库问答 >
问题:

无效的标记-压缩接近堆限制分配角度8-JavaScript堆内存不足

籍英叡
2023-03-14

42%生成274/275模块1活动...\src\index.js??已提取!d:\clients\app\node_modules\sass-loader\lib\loader.js??ref--15-3!d:\src\styles.scss<---最后几个GC---->

[12996:000002DFC57D42F0]43111 ms:清除1335.4(1425.0)->1335.3(1426.0)MB,2.6/0.0ms(平均mu=0.169,当前mu=0.100)分配失败[12996:000002DFC57D42F0]43489ms:标记-清除1336.2(1426.0)->1335.4(1425.5)MB,375.8/0.0ms(平均mu=0.144,当前mu=0.100)分配失败清除可能不会成功

<----JS StackTrace---->

=====JS栈迹==========================================================================

0: ExitFrame [pc: 00000257D3FDC5C1] Security context: 0x00b77541e6e9 <JSObject>
1: createNode [000001A31ED4EFF1] [D:\Clients\app\node_modules\typescript\lib\typescript.js:~16489]

[PC=00000257D55AD889](this=0x02B823CEDF89,kind=275,pos=-=-1,end=-1)2:createPropertyAssignment[000001A31ED54669][d:\clients\app\node_module\typescript\lib\typescri...

致命错误:无效标记-压缩堆限制分配失败-JavaScript堆内存不足1:00007FF76C26DD8A v8::internal::gcidletimehandler::gcidletimehandler+4506 2:00007FF76C248886 node::makeCallback+4534 3:00007FF76C249200 node_module_register+2032 4:00007FF76C5630DE v8::internal::fatalprocessoutofmemory+846 5:00007FF76C56300F v8::internal::fatalprocessoutofmemory+639

我尝试过这个解决方案:https://github.com/angular/Angulal-CLI/issues/5618#issueComment-450151214

即。

package.json

"scripts": {
        "ng": "ng",
        "ng-high-memory": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng",// here
        "start": "ng serve",
        "build:prod": "ng build --configuration=prod",
    },

在那之后

npm运行NG-high-memory--build--prod

但上面写着

> > metronic-angular@6.0.0 ng-high-memory D:\Clients\app
> > node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng
> 
> Available Commands:   add Adds support for an external library to your
> project.   analytics Configures the gathering of Angular CLI usage
> metrics. See https://v8.angular.io/cli/usage-analytics-gathering.  
> build (b) Compiles an Angular app into an output directory named dist/
> at the given output path. Must be executed from within a workspace
> directory.   deploy (d) Invokes the deploy builder for a specified
> project or for the default project in the workspace.   config
> Retrieves or sets Angular configuration values in the angular.json
> file for the workspace.   doc (d) Opens the official Angular
> documentation (angular.io) in a browser, and searches for a given
> keyword.   e2e (e) Builds and serves an Angular app, then runs
> end-to-end tests using Protractor.   generate (g) Generates and/or
> modifies files based on a schematic.   help Lists available commands
> and their short descriptions.   lint (l) Runs linting tools on Angular
> app code in a given project folder.   new (n) Creates a new workspace
> and an initial Angular app.   run Runs an Architect target with an
> optional custom builder configuration defined in your project.   serve
> (s) Builds and serves your app, rebuilding on file changes.   test (t)
> Runs unit tests in a project.   update Updates your application and
> its dependencies. See https://update.angular.io/   version (v) Outputs
> Angular CLI version.   xi18n Extracts i18n messages from source code.
> 
> For more detailed help run "ng [command name] --help"

那么如何才能正确运行这个命令呢?

注意:我使用最新的Angular,即“@Angular/Core”:“^8.2.14”“@Angular/CLI”:“^8.3.19”,

共有3个答案

汪翰墨
2023-03-14

在我的raspbarry pi model 3上,RAM(1GB)和交换空间(1GB)太小了。将交换空间增加到10GB后,建议的命令“ng-high-memory”起作用了!

秦诚
2023-03-14

将节点js版本升级到v12。

计燕七
2023-03-14

这对我有用:

我已更新到最新的Angular版本,如下所示:ng update@Angular/cli@^8@Angular/core@^8

然后

package.json

"scripts": {
    "ng-high-memory": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng build --configuration=prod",
}

之后:

npm run ng-high-memory

URL:JavaScript堆内存不足

 类似资料: