8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

nodenv と arch を使って m1 mac に古いバージョンの node をインストールする

Posted at

エラー

M1 mac + nodenv を利用していてローカルのマイナーバージョンを更新したところ以下のエラーが発生するようになってしまった

.node-version
12.22.9
$ yarn build
yarn run v1.22.10
9% setup compilation ...ePlugin
<--- Last few GCs --->

[61545:0x158008000]      605 ms: Scavenge 33.8 (52.3) -> 22.1 (53.3) MB, 1.5 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure
[61545:0x158008000]      741 ms: Scavenge 36.2 (53.8) -> 25.4 (56.8) MB, 2.5 / 0.1 ms  (average mu = 1.000, current mu = 1.000) allocation failure
[61545:0x158008000]      867 ms: Scavenge 41.2 (58.4) -> 30.4 (61.4) MB, 1.9 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x0001071c08d1 <JSObject>
    0: builtin exit frame: new constructor(aka Module)(this=0x00011162b5a9 <Object map = 0x113058179>,0x00011162b459 <Uint8Array map = 0x1071a59b9>,0x00011162b5a9 <Object map = 0x113058179>)

    1: ConstructFrame [pc: 0x104e34cd8]
    2: StubFrame [pc: 0x104f1d784]
    3: /* anonymous */ [0x111624da1] [/Users/shootani/work/icare/www/node_modules/webpack/lib/util/hash/md4.js:11] [bytecode=0x1130...

FATAL ERROR: wasm code commit Allocation failed - process out of memory
 1: 0x104667178 node::Abort() [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
 2: 0x1046672f8 node::errors::TryCatchScope::~TryCatchScope() [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
 3: 0x10478757c v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
 4: 0x104787510 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
 5: 0x104cbfccc v8::internal::wasm::WasmCodeAllocator::AllocateForCodeInRegion(v8::internal::wasm::NativeModule*, unsigned long, v8::base::AddressRegion) [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
 6: 0x104cc0ba8 v8::internal::wasm::NativeModule::CreateEmptyJumpTableInRegion(unsigned int, v8::base::AddressRegion) [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
 7: 0x104cc0070 v8::internal::wasm::NativeModule::AddCodeSpace(v8::base::AddressRegion) [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
 8: 0x104cc09e4 v8::internal::wasm::NativeModule::NativeModule(v8::internal::wasm::WasmEngine*, v8::internal::wasm::WasmFeatures const&, bool, v8::internal::VirtualMemory, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, std::__1::shared_ptr<v8::internal::Counters>, std::__1::shared_ptr<v8::internal::wasm::NativeModule>*) [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
 9: 0x104cc2c24 v8::internal::wasm::WasmCodeManager::NewNativeModule(v8::internal::wasm::WasmEngine*, v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, unsigned long, bool, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
10: 0x104cc952c v8::internal::wasm::WasmEngine::NewNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, unsigned long, bool, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
11: 0x104cc9474 v8::internal::wasm::WasmEngine::NewNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
12: 0x104ca0f88 v8::internal::wasm::CompileToNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, v8::internal::wasm::ErrorThrower*, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, v8::internal::wasm::ModuleWireBytes const&, v8::internal::Handle<v8::internal::FixedArray>*) [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
13: 0x104cc7120 v8::internal::wasm::WasmEngine::SyncCompile(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, v8::internal::wasm::ErrorThrower*, v8::internal::wasm::ModuleWireBytes const&) [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
14: 0x104ce86a8 v8::(anonymous namespace)::WebAssemblyModule(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
15: 0x1047ebb54 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
16: 0x1047eaebc v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<true>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
17: 0x1047ea9b8 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
18: 0x104eb764c Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
19: 0x104e34cd8 Builtins_JSBuiltinsConstructStub [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
20: 0x104f1d784 Builtins_ConstructHandler [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
21: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
22: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
23: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
24: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
25: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
26: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
27: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
28: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
29: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
30: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
31: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
32: 0x104e31f68 Builtins_ArgumentsAdaptorTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
33: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
34: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
35: 0x104e31f68 Builtins_ArgumentsAdaptorTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
36: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
37: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
38: 0x104e31f68 Builtins_ArgumentsAdaptorTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
39: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
40: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
41: 0x104e31f68 Builtins_ArgumentsAdaptorTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
42: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
43: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
44: 0x104e31f68 Builtins_ArgumentsAdaptorTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
45: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
46: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
47: 0x104e31f68 Builtins_ArgumentsAdaptorTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
48: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
49: 0x104e31f68 Builtins_ArgumentsAdaptorTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
50: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
51: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
52: 0x104e31f68 Builtins_ArgumentsAdaptorTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
53: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
54: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
55: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
56: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
57: 0x104e31f68 Builtins_ArgumentsAdaptorTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
58: 0x104e39aa0 Builtins_InterpreterEntryTrampoline [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
59: 0x104e66444 Builtins_AsyncFunctionAwaitResolveClosure [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
60: 0x104e8ab80 Builtins_PromiseFulfillReactionJob [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
61: 0x104e58440 Builtins_RunMicrotasks [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
62: 0x104e36a0c Builtins_JSRunMicrotasksEntry [/Users/shootani/.nodenv/versions/12.22.9/bin/node]
63: 0x158008000
error Command failed with signal "SIGABRT".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

原因

node の v12 系が arm アーキテクチャに対応していないため

参考:https://stackoverflow.com/questions/65856300/wasm-code-commit-allocation-failed-process-out-of-memory

対応方法

x86_64 アーキテクチャバージョンの node を rosseta2 経由でインストールすることで解決する

# 現在のアーキテクチャを確認する
$ node
Welcome to Node.js v12.22.9.
Type ".help" for more information.
>
> process.arch
'arm64'

# アーキテクチャを指定してインストールし直す
$ uname -m
arm64
$ nodenv uninstall 12.22.9
$ arch -x86_64 ${SHELL}
$ uname -m
x86_64
$ nodenv install 12.22.9
$ exit

# 新しくインストールした node のアーキテクチャを確認する
$ node
Welcome to Node.js v12.22.9.
Type ".help" for more information.
>
> process.arch
'x64'

※ うまくいかない場合、 Rosseta2 が有効になっているかどうかを確認してください

8
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?