Jan 8, 2020· 2 mins to read

How to install nodejs in macos


How to install nodejs in macos

In this article, we will see how to install nodejs in macos. How to Install/Update Nodejs in Mac OSX.

Recent Articles,

TypeScript for React developers in 2020

Implement Multi Threading in Nodejs with a real world use-case

A Complete Guide to AWS Elastic Load Balancer using Nodejs

Basically there are few methods to install Nodejs in Mac. they are,

Using Node version Manager(nvm)

Firstly install the nvm in your machine using the command

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

the above command downloads the binary and stores it in ~/.nvm. Now you need to add the variable in the bash profile.

~/.bash_profile

and add the following code in the 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" # This loads nvm

For Reference : nvm docs

you can verify the installation of nvm using the command

command -v nvm

Now, you can install or update the nodejs using nvm easily

nvm install 10
nvm use 12

Using Node Package Manager(npm)

you can install nodejs using a npm package called n. Once it is installed, make sure to clear the cache using the command

sudo npm cache clean -f

After that install the n npm module in your machine

npm install -g n

Now, you can install the nodejs using the command

n 10.16.0
n lts

Summary

Once you complete the installation of nodejs and npm . you can verify the installation using the command,

npm --version
node --version

it will show you the installed versions of nodejs and npm. How to install nodejs in macos.

Copyright © Cloudnweb. All rights reserved.