Skip to content

Commit 49e806c

Browse files
mcalthropljharb
authored andcommitted
[readme] Add macOS troubleshooting instructions for M1 chip
1 parent 3243f7a commit 49e806c

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

README.md

+52
Original file line numberDiff line numberDiff line change
@@ -871,3 +871,55 @@ Ignore insecure directories and continue [y] or abort compinit [n]? y
871871
```
872872
873873
Homebrew causes insecure directories like `/usr/local/share/zsh/site-functions` and `/usr/local/share/zsh`. This is **not** an `nvm` problem - it is a homebrew problem. Refer [here](https://github.com/zsh-users/zsh-completions/issues/680) for some solutions related to the issue.
874+
875+
**Macs with M1 chip**
876+
877+
_January 2021:_ there are no pre-compiled NodeJS binaries for versions prior to 15.x for Apple's new M1 chip (arm64 architecture).
878+
879+
Some issues you may encounter:
880+
881+
- using `nvm` to install, say, `v14.15.4`:
882+
- the C code compiles successfully
883+
- but crashes with an out of memory error when used
884+
- increasing the memory available to node still produces the out of memory errors:
885+
```sh
886+
$ NODE_OPTIONS="--max-old-space-size=4096" ./node_modules/.bin/your_node_package
887+
```
888+
- when using `nvm` to install some versions, the compilation fails
889+
890+
One solution to this issue is to change the architecture of your shell from arm64 to x86.
891+
892+
Let's assume that:
893+
- you already have versions `12.20.1` and `14.15.4` installed using `nvm`
894+
- the current version in use is `14.15.4`
895+
- you are using the `zsh` shell
896+
897+
```sh
898+
# Check what version you're running:
899+
$ node --version
900+
v14.15.4
901+
# Check architecture of the `node` binary:
902+
$ node -p process.arch
903+
arm64
904+
# This confirms that the arch is for the M1 chip, which is causing the problems.
905+
# So we need to uninstall it.
906+
# We can't uninstall the version we are currently using, so switch to another version:
907+
$ nvm install v12.20.1
908+
# Now uninstall the version we want to replace:
909+
$ nvm uninstall v14.15.4
910+
# Set the architecture for our shell to 64-bit X86:
911+
$ arch -x86_64 zsh
912+
```
913+
914+
At this point in time, we are still in the shell that is running using the M1 architecture.
915+
916+
So we now need to open a new terminal window in order to run our shell in the 64-bit X86 architecture.
917+
918+
```sh
919+
# `node` will not be on the path in this new terminal window.
920+
# So install it:
921+
$ nvm install v14.15.4
922+
# Now check that the architecture is correct:
923+
$ node -p process.arch
924+
x64
925+
```

0 commit comments

Comments
 (0)