DEV Community

Mauricio Panelo
Mauricio Panelo

Posted on

2 2

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!

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay