M1 mac で nodenv install x.x.x
をしようとしたときに以下のエラーがでたので、その対処方法です。
$ nodenv install 8.16.0
Downloading node-v8.16.0.tar.gz...
-> https://nodejs.org/dist/v8.16.0/node-v8.16.0.tar.gz
WARNING: node-v8.16.0 is past its end of life and is now unsupported.
It no longer receives bug fixes or security updates.
Installing node-v8.16.0...
BUILD FAILED (OS X 11.3.1 using node-build 4.9.43)
Inspect or clean up the working tree at /var/folders/7k/4bcqvyqn59ngsw819tg29xd00000gn/T/node-build.20220530225738.25230.3q6zxi
Results logged to /var/folders/7k/4bcqvyqn59ngsw819tg29xd00000gn/T/node-build.20220530225738.25230.log
Last 10 log lines:
1 error generated.
make[1]: *** [/private/var/folders/7k/4bcqvyqn59ngsw819tg29xd00000gn/T/node-build.20220530225738.25230.3q6zxi/node-v8.16.0/out/Release/obj.target/openssl/deps/openssl/asm/arm64-linux64-gas/sha/sha1-armv8.o] Error 1
In file included from ../deps/openssl/asm/arm64-linux64-gas/sha/sha256-armv8.S:1:
../deps/openssl/openssl/crypto/arm_arch.h:46:6: error: "unsupported ARM architecture"
# error "unsupported ARM architecture"
^
1 error generated.
make[1]: *** [/private/var/folders/7k/4bcqvyqn59ngsw819tg29xd00000gn/T/node-build.20220530225738.25230.3q6zxi/node-v8.16.0/out/Release/obj.target/openssl/deps/openssl/asm/arm64-linux64-gas/sha/sha256-armv8.o] Error 1
rm 0f013dca09e35835b3d7c9ba7bcc5609f886b7cc.intermediate
make: *** [node] Error 2
環境
- macOS Big Sur(バージョン 11.3.1)
- nodenv 1.4.0
対応
古いバージョンの Node は ARM に対応してないしていないとのことなので、Intel モードのコンソール(Rosetta)で、操作する必要がある。
1. ターミナルの「情報」を開く
2. 「Rosettaを使用して開く」にチェックを入れる
3. Rosetta モードのターミナルを開く
先ほどエラーが出ていたコマンドを打つと、エラーが出ずにインストールができるようになっています。
$ nodenv install 8.16.0
Downloading node-v8.16.0-darwin-x64.tar.gz...
-> https://nodejs.org/dist/v8.16.0/node-v8.16.0-darwin-x64.tar.gz
WARNING: node-v8.16.0-darwin-x64 is past its end of life and is now unsupported.
It no longer receives bug fixes or security updates.
Installing node-v8.16.0-darwin-x64...
Installed node-v8.16.0-darwin-x64 to /Users/xxxxx/.anyenv/envs/nodenv/versions/8.16.0
$ nodenv versions
* 8.16.0
14.17.1
4. ターミナルの設定を戻す
インストールが終わったら、先ほどチェックを入れた「Rosettaを使用して開く」のチェックを外します。
おわり。