Getting your macOS ready for development involves installing a few essential tools: Xcode, NVM, and NPX. Here’s a quick and easy guide to get you started.
Installing Homebrew
Homebrew is a package manager for macOS that simplifies the installation of software. Open Terminal and enter the following command to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Installing Xcode Command Line Tools
Xcode Command Line Tools are necessary for compiling software on your Mac. In Terminal, run:
xcode-select - install
Installing NVM (Node Version Manager)
NVM allows you to manage multiple versions of Node.js. To install NVM, open Terminal and use this command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
Next, add the following lines to your ~/.zshrc or ~/.bash_profile:
export NVM_DIR=”$([ -z “${XDG_CONFIG_HOME-}” ] && printf %s “${HOME}/.nvm” || printf %s “${XDG_CONFIG_HOME}/nvm”)”
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Reload your terminal configuration with:
source ~/.zshrc # or source ~/.bash_profile
Installing Node.js Using NVM
With NVM installed, you can easily install and manage Node.js versions. In Terminal, install the latest Node.js version by running:
nvm install node
Set the default Node.js version with:
nvm alias default node
Verifying NPX Installation
NPX comes with Node.js versions 8.2.0 and higher. Ensure it’s installed by checking its version. In Terminal, run:
npx -v
Conclusion
By following these steps, you’ve set up your macOS for development with Xcode, NVM, and NPX. Enjoy!