20 January 2021
At the time of writing, there are no pre-compiled NodeJS binaries for versions prior to 15.x for Apple's new M1 chip (arm64 architecture).
Additional issues encountered:
- when I used
nvm
to install the version I required (14.15.4)- it compiled the C code successfully
- but crashed with an out of memory error
- I tried increasing the memory available to node, but still got the oom errors:
$ NODE_OPTIONS="--max-old-space-size=4096" ./node_modules/.bin/snowpack dev
- when I used
nvm
to install other versions (I forget which ones now), the compilation actually failed
Assumptions:
- I currently have versions
12.20.1
and14.15.4
installed usingnvm
- the current version in use is
14.15.4
# Check what version I'm running:
$ node --version
v14.15.4
# Check architecture of the `node` binary:
$ node -p process.arch
arm64
# Confirms that the arch is for the M1 chip, which is causing the problems.
# So I need to uninstall it.
# Can't uninstall the one I'm currently using, so switch to another version:
$ nvm install v12.20.1
# Now I can uninstall the version I want to replace:
$ nvm uninstall v14.15.4
# Set the architecture for my shell to 64-bit X86:
$ arch -x86_64 zsh
At this point in time, I'm still in the shell that is running using the M1 architecture.
So I now need to open a new terminal window in order to run my shell in the 64-bit X86 architecture.
# `node` will not be on the path in this new terminal window.
# So install it:
$ nvm install v14.15.4
# Now check that the architecture is correct:
$ node -p process.arch
x64
Original source: nvm-sh/nvm#2350 (comment)
The instructions in that GitHub issue comment didn't quite work for me, hence creating this gist to reflect what I found to work.
this is super helpful, thanks 👍