강의

멘토링

커뮤니티

인프런 커뮤니티 질문&답변

Moa Kim님의 프로필 이미지
Moa Kim

작성한 질문수

[리뉴얼] React로 NodeBird SNS 만들기

AWS에서 메모리부족 빌드 안되는 문제>

해결된 질문

작성

·

1.8K

0

올려주신 타입스크립트-리액트쿼리 기반으로

연습용 프로젝트 만들어서 AWS에서 npm build를 했는데 에러가 발생하네요.

로컬에선 빌드가 정상적으로 됐습니다.

back은 aws에서 정상적으로 작동하고 front 빌드가 실패하네요.

 

 

 

서버는 강의에 나온 그대로 무료서버 선택했습니다.

AWS 로그는 이러합니다.

 

> excuse-moa-front-rq@1.0.0 build /home/ubuntu/excuse-moa/front_rq

> cross-env ANALYZE=true NODE_ENV=production next build

 

info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5

info  - Checking validity of types  

error - ESLint: Failed to load config "airbnb" to extend from. Referenced from: /home/ubuntu/excuse-moa/front_rq/.eslintrc.js

info  - Using external babel configuration from /home/ubuntu/excuse-moa/front_rq/.babelrc

info  - Creating an optimized production build .

<--- Last few GCs --->

 

[11366:0x53d8700]    68649 ms: Mark-sweep (reduce) 485.5 (491.0) -> 484.3 (491.5) MB, 775.4 / 0.0 ms  (average mu = 0.186, current mu = 0.085) allocation failure scavenge might not succeed

[11366:0x53d8700]    68736 ms: Scavenge (reduce) 485.4 (490.5) -> 484.5 (491.5) MB, 4.6 / 0.0 ms  (average 

mu = 0.186, current mu = 0.085) allocation failure

[11366:0x53d8700]    68823 ms: Scavenge (reduce) 485.4 (493.5) -> 484.8 (493.7) MB, 26.9 / 0.0 ms  (average mu = 0.186, current mu = 0.085) allocation failure

 

 

<--- JS stacktrace --->

 

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

 1: 0xa38a30 node::Abort() [node]

 2: 0x96e0af node::FatalError(char const*, char const*) [node]

 3: 0xbb7ebe v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]

 4: 0xbb8237 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]   

 5: 0xd74445  [node]

 6: 0xd74fcf  [node]

 7: 0xd82e0b v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]

 8: 0xd869cc v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]

 9: 0xd550ab v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]

10: 0x109d68f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) 

[node]

11: 0x14467f9  [node]

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! excuse-moa-front-rq@1.0.0 build: `cross-env ANALYZE=true NODE_ENV=production next build`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the excuse-moa-front-rq@1.0.0 build script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

 

npm ERR! A complete log of this run can be found in:

npm ERR!     /root/.npm/_logs/2022-01-23T08_23_06_820Z-debug.log

 

 

에러 발생후 package-lock.json, node_modules 삭제하고 재시도 했는데 그대로네요.

allocation failure면 메모리부족같긴 한데 원인이

tree-shaking 못한 최적화 문제인지 그저 서버 램부족인지

제가 놓친게 있는건지 궁금합니다.

답변 1

0

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

t2.micro라서 서버 메모리가 부족한 것입니다. t3.small로 올리면 되긴 한데 비용이 나가니 로컬에서 빌드하고 .next 폴더 github으로 올려서 pull 받아서 실행하세요.

Moa Kim님의 프로필 이미지
Moa Kim
질문자

감사합니다 말씀하신대로 로컬에서 빌드후  scp로 aws에 next 폴더 업로드해서 해결했습니다.

Moa Kim님의 프로필 이미지
Moa Kim

작성한 질문수

질문하기