Skip to content

Instantly share code, notes, and snippets.

@domtra
Last active May 14, 2021 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domtra/67464841a3583f73b7134a5f6d3a3fd2 to your computer and use it in GitHub Desktop.
Save domtra/67464841a3583f73b7134a5f6d3a3fd2 to your computer and use it in GitHub Desktop.

setup tapas

nodejs on am64

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.

parallel installation of composer versions 1 and 2

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.

Switching PHP versions in the terminal

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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment