为了账号安全,请及时绑定邮箱和手机立即绑定

在ec2中为reactjs运行npm start时出错

在ec2中为reactjs运行npm start时出错

MMMHUHU 2021-11-12 17:32:05
我试图在 AWS ec2 上部署我的节点和反应应用程序,节点应用程序工作正常,但反应应用程序在npm run build上出错也尝试过npm start,但仍然出现相同的错误。这是错误尝试设置 NODE_OPTIONS=--max_old_space_size=8172以增加内存,但错误仍然相同Security context: 0x0f19d05408a1 <JSObject>    2: visitQueue [0x581c2dbffa1] [/home/ubuntu/expert-erp/source/node_modules/@babel/traverse/lib/context.js:~96] [pc=0x302cbe090747](this=0x2c145b2a5559 <TraversalContext map = 0x32c1b0aaf1e1>,0x2c145b2a55a1 <JSArray[1]>)    3: visitMultiple [0x581c2dbbd11] [/home/ubuntu/expert-erp/source/node_modules/@babel/traverse/lib/contex...FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memoryWriting Node.js report to file: report.20191008.111057.11400.0.001.jsonNode.js report completed 1: 0x9d33e0 node::Abort() [node] 2: 0x9d4596 node::OnFatalError(char const*, char const*) [node] 3: 0xb32dbe v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node] 4: 0xb33139 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node] 5: 0xcde455  [node] 6: 0xcdeae6 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node] 7: 0xcea97a v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node] 8: 0xceb885 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node] 9: 0xcee298 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [node]10: 0xcb4bc7 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType) [node]11: 0xfeaafb v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]12: 0x136d539  [node]npm ERR! code ELIFECYCLEnpm ERR! errno 1npm ERR! Expert-Board@0.0.1 build: `react-scripts build`npm ERR! Exit status 1npm ERR!
查看完整描述

2 回答

?
繁花不似锦

TA贡献1851条经验 获得超4个赞

该问题与 react-scripts 空间大小无关。

是EC2实例大小问题,增加实例内存后运行完美。

(注意:我试图在带有 8GB SSD 和 0.8GB RAM 的 EC2 免费层上运行它,在同一个实例上运行两个应用程序是不够的。但是在将实例更改为 2GB RAM 后,有完全没有问题。)


查看完整回答
反对 回复 2021-11-12
?
桃花长相依

TA贡献1860条经验 获得超8个赞

如果您使用的是 react-scripts 或 create-react-app,那么您可以尝试以下操作:

反应脚本 --max_old_space_size=8172 开始


查看完整回答
反对 回复 2021-11-12
  • 2 回答
  • 0 关注
  • 148 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信