This note is to supplement the instructions on the official Truffle install page
The steps below have been tested on:
macOS 10.15.7 (Catalina)
macOS 12.3.1 (Monterey)
To avoid permission errors when installing packages globally npm recommends installing nodejs with a version manager.
First, install the xcode command line tools:
Install a node version manager, we will use nvm, see full instructions here
Create an empty .zshrc (or .bashrc, or other) - the nvm install script won’t add config automatically if you don’t have one:
Copy this line from the above page and paste into a terminal:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Then install nodejs with:
nvm install --lts
The above xcode-select --install step has already installed node-gyp’s dependencies.
npm install -g truffle
You will see some warnings but there shouldn’t be any errors.
Test the install with:
and then something harder such as:
mkdir truffle_test cd truffle_test truffle init
Now you can return to the quickstart and explore a working truffle installation.