Node提供了通过传递--max-old-space-size
命令行标志来增加堆大小的方法。
在create-react-app项目中,一切都取决于使用react-scripts。
我该如何在这样的项目中传入此参数,并在哪里最好执行?
谢谢您的帮助。
Node提供了通过传递--max-old-space-size
命令行标志来增加堆大小的方法。
在create-react-app项目中,一切都取决于使用react-scripts。
我该如何在这样的项目中传入此参数,并在哪里最好执行?
谢谢您的帮助。
非常感谢@dan-abramov,他的评论就是答案!(如果您看到这条消息,请给他点赞)。
您只需将例如node --max_old_space_size=4096 node_modules/.bin/react-scripts start
放入其中,而不是react-scripts start
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
。 - fabpico"build": "react-scripts --max_old_space_size=4096 build"
这应该可以工作
FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
。 - fabpico一行命令,在终端中输入 -> export NODE_OPTIONS=--max_old_space_size=4096
如果您正在使用craco build
,只需像下面这样添加标志
craco --max_old_space_size=4096 build
添加
ENV GENERATE_SOURCEMAP=false
node_modules/.bin/react-scripts
作为参数传递给它。它与实际脚本建立了符号链接。 - Dan Abramov