nodejs在M1报错

更新于 阅读 12

M1芯片安装依赖的时候会报错:

<--- JS stacktrace --->

FATAL ERROR: wasm code commit Allocation failed - process out of memory
 1: 0x10431b740 node::Abort() [/Users/xxx/.nvm/versions/node/v14.16.0/bin/node]
 2: 0x10431b8c0 node::errors::TryCatchScope::~TryCatchScope() [/Users/xxx/.nvm/versions/node/v14.16.0/bin/node]
 3: 0x104434960 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/xxx/.nvm/versions/node/v14.16.0/bin/node]
 4: 0x1044348f4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/xxx/.nvm/versions/node/v14.16.0/bin/node]
 5: 0x1049c9720 v8::internal::wasm::WasmCodeAllocator::AllocateForCodeInRegion(v8::internal::wasm::NativeModule*, unsigned long, v8::base::AddressRegion, v8::internal::wasm::WasmCodeAllocator::OptionalLock const&) [/Users/xxx/.nvm/versions/node/v14.16.0/bin/node]
 6: 0x1049ca3ac v8::internal::wasm::NativeModule::CreateEmptyJumpTableInRegion(int, v8::base::AddressRegion, v8::internal::wasm::WasmCodeAllocator::OptionalLock const&) [/Users/xxx/.nvm/versions/node/v14.16.0/bin/node]
 7: 0x1049c907c v8::internal::wasm::NativeModule::AddCodeSpace(v8::base::AddressRegion, v8::internal::wasm::WasmCodeAllocator::OptionalLock const&) [/Users/xxx/.nvm/versions/node/v14.16.0/bin/node]

这是由于node的版本不兼容引起的,可以升级到node版本到16