【问题标题】:npx create-react-app fatal error: JavaScript heap out of memorynpx create-react-app 致命错误:JavaScript 堆内存不足
【发布时间】:2021-09-26 03:04:37
【问题描述】:

尝试使用 npx create-react-app 评估为 React 应用创建样板

D:\React>create-react-app assessment

Creating a new React app in D:\React\assessment.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

[          ........] | reify:color-convert: timing reifyNode:node_modules/jest-validate/node_modules/color-convert Comp

#
# Fatal error in , line 0
# Fatal process out of memory: Zone
#
#
#
#FailureMessage Object: 000000888EBFA4C0[          ........] / reify:color-convert: timing reifyNode:node_modules/jest-s[          ........] / reify:color-convert: timing reifyNode:node_modules/jest-snapshot/node_modules/color-convert Comp
<--- Last few GCs --->

[7756:000001A77FCE9290]   304467 ms: Scavenge 239.7 (274.6) -> 239.1 (274.6) MB, 2.8 / 0.0 ms  (average mu = 0.996, current mu = 0.999) allocation failure
[7756:000001A77FCE9290]   306201 ms: Scavenge 239.8 (274.6) -> 239.3 (274.6) MB, 186.4 / 181.9 ms  (average mu = 0.996, current mu = 0.999) allocation failure
[7756:000001A77FCE9290]   307086 ms: Scavenge 240.1 (274.6) -> 239.6 (274.6) MB, 3.9 / 0.1 ms  (average mu = 0.996, current mu = 0.999) allocation failure


<--- JS stacktrace --->

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

    0: ExitFrame [pc: 00007FF647760366]
    1: StubFrame [pc: 00007FF647761333]
    2: StubFrame [pc: 00007FF647732BAD]
Security context: 0x0364ad71a299 <JSObject>
    3: replace [00000364AD709699](this=0x03c776effa81 <String[175]\: [\x1b[7m          \x1b[27m\x1b[90m........\x1b[0m] / reify:color-convert: \x1b[32;40mtiming\x1b[0m \x1b[35mreifyNode:node_modules/jest-snapshot/node_modules/color-convert\x1b[0m Completed in 194645ms>,0x03b334...

FATAL ERROR: Committing semi space failed. Allocation failed - JavaScript heap out of memory

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Deleting assessment/ from D:\React

以上痕迹来自 CMD 也尝试使用管理员权限,但仍然是同样的问题。 还尝试通过npm clean cache --force 清理 NPM 缓存,但问题仍然存在, 如果有人可以提供同样的帮助!!

使用节点版本 12.2.0 和 npm 版本 7.20.0

【问题讨论】:

    标签: javascript reactjs npm


    【解决方案1】:

    This answer 看起来可能是相关的。

    不过,我建议您先将您的 NodeJS 版本升级到最新的 12.x 或最高 14.x(如果可能的话)。

    您还需要确保您获得的是最新的create-react-app,因为问题可能在于旧版本的NodeJScreate-react-app 冲突。

    在您更新内容后,我将使用 create-react-app guide 中的 npx create-react-app assessments 来创建您的应用程序,看看情况如何。

    【讨论】:

    • 是的,对一些遗留节点问题进行故障排除可能很困难。升级并重试可能是最好的选择。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-11
    • 1970-01-01
    • 1970-01-01
    • 2018-11-05
    • 2021-04-24
    • 2021-03-03
    • 2018-11-10
    相关资源
    最近更新 更多