Setting macOS development environment

These days I maked a new installation of new macOS Big Sur from scratch, so I needed to install some stuffs to development.

1. What's brew?

It's a package manager to macOS, You can search and install any software from here, without the necessity to download the file directly from web.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2. What's nvm?

Nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL.

To install or update nvm, you should run the install script. To do that, use the following cURL command:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash

The script clones the nvm repository to ~/.nvm, and attempts to add the source lines from the snippet below to the correct profile file (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).

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" # This loads nvm

2.1 Installing NodeJS

You can list available versions using ls-remote:

nvm ls-remote

You can check all available versions here, I recommend to use the lastest LTS version supported, here we use node v16.17.0

nvm install v16.18.1

To check if it's working

node -v

It should be v16.18.1

3. Installing Yarn

Yarn is a package manager for NodeJS

You can install Yarn by running the following code in your terminal:

npm install -g yarn

References