npm run buildメモリ不足の問題解決

3363 ワード

ubuntu@ip-10-200-100-47:~/pinpoint-backend$ npm run build
> [email protected] prebuild /home/ubuntu/pinpoint-backend
> rimraf dist
> [email protected] build /home/ubuntu/pinpoint-backend
> nest build

[2667:0x438f440]    29476 ms: Mark-sweep 489.6 (493.3) -> 489.1 (493.3) MB, 788.7 / 0.0 ms  (average mu = 0.145, current mu = 0.043) allocation failure scavenge might not succeed
[2667:0x438f440]    30431 ms: Mark-sweep 489.8 (493.3) -> 489.4 (493.5) MB, 906.5 / 0.0 ms  (average mu = 0.096, current mu = 0.051) allocation failure scavenge might not succeed

==== JS stack trace =========================================
    0: ExitFrame [pc: 0x13a71b9]
Security context: 0x165d198008d1 
    1: getWidenedTypeWithContext(aka getWidenedTypeWithContext) [0x985c78905d9] [/home/ubuntu/pinpoint-backend/node_modules/typescript/lib/typescript.js:~48560] [pc=0x2c5421263069](this=0x183786cc04b1 ,0x1586cbccffe9 ,0x183786cc04b1 )
    2: getTypeOfVariableOrParameterOrPropertyWorker(aka getTypeOfVariableOr...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Writing Node.js report to file: report.20200422.051346.2667.0.001.json
Node.js report completed
 1: 0x9ef190 node::Abort() [node]
 2: 0x9f13b2 node::OnFatalError(char const*, char const*) [node]
 3: 0xb5da9e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xb5de19 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xd0a765  [node]
 6: 0xd0adf6 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
 7: 0xd1760a v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
 8: 0xd18515 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 9: 0xd1afcc v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
10: 0xce19bb v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
11: 0x10246ce v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
12: 0x13a71b9  [node]
Aborted (core dumped)
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! [email protected] build: `nest build`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the [email protected] 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!     /home/ubuntu/.npm/_logs/2020-04-22T05_13_46_737Z-debug.log

swapテクノロジーによるハードディスク(HDD)領域のメモリとしての使用
https://juejin.im/post/5c638e7ae51d457fa676dfed
https://serverfault.com/questions/897756/delete-a-file-that-was-created-with-fallocate
fallocate just creates a file, it does nothing specific to swap, so you can simply rm /swapfile.

If you had turned it into a swapfile with mkswap then swapon you can simply use swapoff /swapfile to stop your machine using it as swap.