npm build 给出了“接近堆限制的无效标记压缩分配失败"; [英] npm build gives "Ineffective mark-compacts near heap limit Allocation failed"

查看:55
本文介绍了npm build 给出了“接近堆限制的无效标记压缩分配失败";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 reactjs/typescript 项目,在 Windows 10 上运行.我试图用 ts-scripts 构建

I have a reactjs/typescript project, running on windows 10. Im trying to build by ts-scripts with

"rimraf ../wwwroot/* && react-scripts-ts build && copyfiles./build/**/* ../wwwroot/-u 1

"rimraf ../wwwroot/* && react-scripts-ts build && copyfiles ./build/**/* ../wwwroot/ -u 1

这之前工作正常,但是当我删除 node_modules-folder 时,重新运行 npm install-command 然后上面的命令我收到错误消息

This has worked ok before, but when I removed the node_modules-folder, re-run the npm install-command and then the command above I get the error message

致命错误:在堆限制分配附近无效的标记压缩失败 - JavaScript 堆内存不足

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

我不知道为什么.谷歌搜索后我看到了

I have no idea why. After googling Ive seen

NODE_OPTIONS="–max-old-space-size=2048"但我不知道把这个放在哪里

NODE_OPTIONS="–max-old-space-size=2048" but I dont know where to put this

完整的错误信息

最后几次 GC

[11376:0000024682F49880]    60039 ms: Mark-sweep 2034.1 (2085.2) -> 2033.7 (2085.2) MB, 1029.4 / 0.0 ms  (average mu = 0.073, current mu = 0.006) allocation failure scavenge might not succeed
[11376:0000024682F49880]    61094 ms: Mark-sweep 2034.4 (2085.2) -> 2034.1 (2085.7) MB, 1047.7 / 0.0 ms  (average mu = 0.039, current mu = 0.007) allocation failure scavenge might not succeed


 JS stacktrace 
==== JS stack trace =========================================

    0: ExitFrame [pc: 000001CDF84DC5C1]
Security context: 0x007044b9e6e1 <JSObject>
    1: bindChildrenWorker(aka bindChildrenWorker) [000001AD1C0ACD59] [C:\Users\robcar\source\repos\Boost\Boost.Web\ClientApp\node_modules\typescript\lib\typescript.js:~27657] [pc=000001CDF8FA47CA](this=0x03da79d826f1 <undefined>,node=0x034b8724ab71 <NodeObject map = 000000660468F931>)
    2: bind(aka bind) [000001AD1C0AE2D9] [C:\Users\robcar\source\repos\B...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF6B5EA121A v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4810
 2: 00007FF6B5E7A5B6 node::MakeCallback+4518
 3: 00007FF6B5E7AFA0 node_module_register+2160
 4: 00007FF6B610B3EE v8::internal::FatalProcessOutOfMemory+846
 5: 00007FF6B610B31F v8::internal::FatalProcessOutOfMemory+639
 6: 00007FF6B6649304 v8::internal::Heap::MaxHeapGrowingFactor+11476
 7: 00007FF6B663FA67 v8::internal::ScavengeJob::operator=+25543
 8: 00007FF6B663DFDC v8::internal::ScavengeJob::operator=+18748
 9: 00007FF6B6646F57 v8::internal::Heap::MaxHeapGrowingFactor+2343
10: 00007FF6B6646FD6 v8::internal::Heap::MaxHeapGrowingFactor+2470
11: 00007FF6B61E9DD7 v8::internal::Factory::NewFillerObject+55
12: 00007FF6B6281ABA v8::internal::WasmJs::Install+29530
13: 000001CDF84DC5C1

推荐答案

我遇到了类似的问题,但在 Mac 计算机上.设置环境变量对我有用.这样,您的节点进程将获取该值并独立于您正在运行的脚本使用它.

I had a similar issue, although on a Mac computer. Setting an environment variable did the trick for me. That way, your node process will take the value and use it independently of which script you're running.

export NODE_OPTIONS=--max_old_space_size=4096

再次运行您的命令.祝你好运!

The run your command again. Good Luck!

这篇关于npm build 给出了“接近堆限制的无效标记压缩分配失败";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆