DEV Community

Mauricio Panelo
Mauricio Panelo

Posted on

The Easiest Way To Install Node.js on Linux/MacOS

I've been riding the learn (build) in public wave for the past month.

Here's what I've been doing:

  • I code or learn for an hour
  • Report my progress on Twitter
  • Push my code to GitHub for others to see

I started learning Typescript a week ago. When I started setting up my laptop for Typescript, I needed to find a way to install Node.

I found that Node Version Manager (nvm) was one of the easiest way to install Node.

Installing nvm is super easy

You find the instructions on the official repository. Run the following:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

Then paste the following in your profile file:

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
Enter fullscreen mode Exit fullscreen mode

If you face any issues, refer to the README.

Install Node using nvm

Installing a specific version of Node:

nvm install <SPECIFIC_NODE_VERSION>
Enter fullscreen mode Exit fullscreen mode

Installing the latest LTS version:

nvm install --lts
Enter fullscreen mode Exit fullscreen mode

Using the installed Node version

Switching between Node versions is simple when using nvm. This is helpful when your different Node projects use different versions.

You can choose which Node version you want to use:

nvm use <SPECIFIC_NODE_VERSION>
Enter fullscreen mode Exit fullscreen mode

Conclusion

I recommend installing nvm. It simplifies the process of installing NodeJS. The bonus is having different versions of NodeJS installed.

Let me know what you think. Are there better alternatives? Suggestions?

Thank you for reading!

Top comments (0)