Node.js installation on Mac and Linux (with nvm)

Posted on: February 3rd, 2024
By: Tadeo Martinez

You can find this information on the Gutenberg Node.js development environment.

Open the terminal and run the following to install nvm. On macOS, the required developer tools are not installed by default. Install them if prompted.

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

Quit and restart the terminal.

Run nvm install --lts in the terminal to install the latest LTS (Long Term Support) version of Node.js.

Run node -v and npm -v in the terminal to verify the installed node and npm versions.

If needed, you can also install specific versions of node. For example, install version 18 by running nvm install 18, and switch between different versions by running nvm use [version-number]. See the nvm usage guide for more details.

Some projects, like Gutenberg, include an .nvmrc file which specifies the version of node that should be used. In this case, running nvm use will automatically select the correct version. If the version is not yet installed, you will get an error that tells you what version needs to be added. Run nvm install [version-number] followed by nvm use.

Have any questions or comments? Write them below!


Leave a Reply

Your email address will not be published. Required fields are marked *