Unfortunately nodejs does not provide compiled binaries for all nodejs version on arm64 at the moment. And propably never will. Only starting with version 15, you can easily install nodejs on arm64 without having to got through a lenghty compilation.
Additionally, not all node modules support arm64. Especially node-sass does not have arm64 support as of now.
With rosetta, however, we can run most nodejs applications successfully.
In order to not get confused what node version was installed with what architecture support, we can use the following strategy.
You should have ~/bin
in your $PATH
. Check by running echo $PATH
.
Create the file ~/bin/nave86
with the following content:
NAVE_DIR="$HOME"/.nave86 arch -x86_64 nave "$@"
Run chmod +x ~/bin/nave86
to make the file executable.
Whenever you want to install nodejs on x86_64
, that is Intel / rosetta architecture, use the command nave86
instead of nave
.
As a consequence, make sure, that if you want to work on projects with nodejs < 15, you change the nave use
commands in the projects ./run
file to nave86
.
If you installed composer
via homebrew, a brew upgrade
will have updated it to version 2 already.
Using composer
version 2 in projects for version 1 will most likely lead to errors.
In order to have both versions installed go to https://getcomposer.org/download/
and follow the instruction. But instead of running php composer-setup.php
, you run
php composer-setup.php --filename=composer1 --install-dir="$HOME"/bin --1
You should have ~/bin
in your $PATH
. Check by running echo $PATH
.
Now, whenever you want to use composer
version 1, run composer1
instead of just composer
.
By default, you will have the latest PHP version available in your terminal. So php -v
will return 8.0.6
for example.
If you need a different version for running commands in a project, you will need to switch the available PHP version.
If you want to have PHP 7.4 available, which is our default PHP version, the quickest way is with the following command:
brew link --force --overwrite php@7.4
The cleanest way would be to first unlink the current PHP version like
brew unlink php@8.0 && brew link --force php@7.4
Both of these ways will result in a persistant change of the available PHP version (until the latest PHP version is updated via brew upgrade
).
The is also a way to only switch the available PHP Version for the current shell session. For example for PHP 7.4, this would be
export PATH="/opt/homebrew/opt/php@7.4/bin:$PATH"
export PATH="/opt/homebrew/opt/php@7.4/sbin:$PATH"