Node.js is an opensource JavaScript platform for general-purpose programming that enables customers to rapidly construct community functions. Because it makes use of JavaScript on each the entrance and backend, improvement turns into much more constant and built-in. 

Node.js runs on varied platforms (Home windows, Linux, Unix, Mac OS, and so forth.) On this tutorial, we are going to focus on about Node.js set up on macOS.

As we have now already talked about, Node.js means that you can write JavaScript on the server-side.  JavaScript, as you recognize, is a browser-based language. The creator of Node.js took the engine of Chrome and set it to work on a server. The browser’s engine compiles JavaScript code into instructions, and the language could be interpreted in an surroundings.   

Npm is the platform for Node.js package deal administration. It presents a software for Node.js libraries to be put in, and their variations and dependencies managed.


{Hardware} Requirement:

  • RAM: 4 GB 
  • Storage: 256 GB of Exhausting Disk House

  Software program Necessities:

  • Net Browser: Any browser reminiscent of Google Chrome, Mozilla Firefox, Microsoft Edge, Safari.
  • XCode: XCode software program is utilized by Apple in constructing Mac and iOS functions, so it supplies the devices it’s essential compile Mac software program. You will discover XCode within the Apple App Retailer.  
  • Homebrew: Homebrew is a package deal supervisor for the Mac. It readily permits the set up of most open-source software program (like Node).  On the Homebrew web site, you could find out extra about Homebrew.
  • Working System: macOS

Set up Process

On this article, we’re going to have a look at three alternative ways to put in Node.js on macOS.

  1. utilizing the macOS installer  
  2. utilizing homebrew  
  3. utilizing Node Model Supervisor

So, allow us to begin.

1. Utilizing the macOS installer

Step 1: Go to the Node.js web site to replace your Mac platform with the constructed installer.

Node.js updates comprise two sorts, long-term help (LTS) and new releases. LTS variations are refined and bug-free, and are enough for many every day customers. Present variations (Newest LTS 14.16.1) are extra experimental and embody the brand new performance, which can’t be accomplished or crashed on occasion. By highlighting the sector on the primary tab, you possibly can transfer between LTS and present variations. Once more, most customers use the LTS model. Subsequently, you possibly can simply click on on macOS installer, which can obtain the Node.js installer, if the LTS tab is highlighted in darkish inexperienced.

Step 2: Obtain .pkg installer and open the downloaded file with default installer.

Step 3: After working the .pkg installer, observe the directions on the interface.

1. Introduction window: choose Proceed

2. Licence window: Choose Proceed and a pop-up window will ask you to agree or disagree. Click on on Conform to proceed.

3. Choose Set up and Authenticate your macOS password.

4. You will notice that Node.js and npm are put in on the interface.

Step 4: Confirm the set up of Node.js and npm through the use of the next instructions on the terminal:

node -v
npm -v

Utilizing homebrew to put in and replace Node.js

Although there are plenty of options within the command line interface of macOS, Linux and different Unix techniques wouldn’t have an honest package deal supervisor. A Package deal Supervisor consists of a collection of software program instruments that routinely set up, configure and replace the software program.

They handle the software program in a central location and keep all of the machine software program packages in broadly used codecs. The Homebrew software program package deal administration framework is free and open-source and simplifies the set up of macOS software program. The newest model of Node.js could be put in utilizing Homebrew.

Step 1: Use the next command to put in Homebrew:

s$ /usr/bin/ruby -e "$(curl -fsSL up/grasp/set up)"

When CURL downloads the script, the Ruby-interpreter begins the Homebrew set up course of, which ships with macOS.

Throughout the operation, you’ll be requested to enter your password. Whilst you do not see them, the machine data your keystrokes, so as soon as your password has been entered, click on the RETURN key.

Step 2: As soon as homebrew is put in, use the next command to put in Node.js:

$ brew replace
$ brew set up node

Step 3: Confirm the set up and verify the model of Node.js and npm.

$ node -v
$ npm -v

Homebrew at all times installs solely the newest model of Node.js. This can be problematic since a sure model of Node.js may be required to operate in functions. It may be a very good factor to have the liberty to make use of these variations. The simplest approach to remedy this drawback is through the use of NVM, the Node Model Supervisor.

Utilizing nvm to put in and replace Node.js

NVM is a bash script for a number of energetic variations of Node.js. Observe these steps to put in Node.js:

Step 1: The script copies the nvm-repository to ~/.nvm after which attaches the sources to the profile of the shell: ~/.bash profile, ~/.zshrc and ~/.profile or ~/.bashrc. Relying on what you’ve got in your machine you should utilize curl

Use the next command:

$ curl -o- | bash

Step 2:  Add the supply strains in your shell profile. You should utilize ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc. On this article, we shall be utilizing zsh shell:

$ vim .zshrc

Step 3: Paste the next strains of code:

export NVM_DIR="$HOME/.nvm"[ -s "$NVM_DIR/" ] && . "$NVM_DIR/" [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"

Shut the file through the use of esc + w + q

Step 4: Use the next command to reload the shell:

$ supply ~/.zshrc

Step 5: You may confirm the set up with the next command and if the display screen proven had nvm written because the output, then the set up is profitable.

$ command -v nvm

Notice: You may verify the varied instructions of nvm with the next command:

$ nvm + tab key

Step 6: Set up LTS model:

$ nvm set up –lts

Step 7: Set up the newest model of node:

$ nvm set up node

That is an alias for the newest model.

Step 8: You may listing out all of the put in Node.js variations accessible in your system:

$ nvm listing

Step 9: Set up NPM:

$ nvm install-latest -npm

Step 10: This installs the newest NPM. After you have arrange NPM, you possibly can check out plenty of helpful instructions:

Checklist and replace globally put in packages:

$ npm ls -g  --depth=0
$ npm replace  -g

Create a easy Program

Let’s create a easy program “Whats up, world.” This ensures that our surroundings works and that you may construct and run a Node.js program conveniently.

Step 1: So as to load the http module and retailer the returned HTTP occasion in a http variable, we use the directive:

var http = require("http");

Step 2: To construct a server occasion, use the created http occasion and name http.createServer() and join it to port 8081 by the servers occasion. Go a operate with request and response parameters. We are going to print Whats up World!

http.createServer(operate (request, response) {
   // Ship the HTTP header  
   // HTTP Standing: 200 : OK
   // Content material Sort: textual content/plain
   response.writeHead(200, {'Content material-Sort': 'textual content/plain'});
   response.finish('Whats up Worldn');
}).pay attention(8081);
console.log('Server working at');

The above code is enough to arrange an HTTP server that listens on the native machine over 8081 port.

Step 3: Create a howdy.js file utilizing the next command:

$ nano howdy.js

Step 4: We are going to mix each the steps in a file howdy.js and begin our http server:

Shut the terminal by saving the file with CTRL + O after which exit it with CTRL + X.

Step 5: Execute the howdy.js to start out the server with the next command:

$ node howdy.js

Step 6: Verify the server at

Lastly, we have now our first http server up.

Uninstall Node.js on macOS

Earlier we have now mentioned the set up of Node.js on Mac with three totally different strategies. Now, we are going to focus on the alternative ways to uninstall Node.js out of your system:

1. Manually

You’ll most likely need to manually take away the executable node and different instruments you probably have put in node both by supply or binary distribution. This isn’t easy, sadly, as a result of a number of folders, reminiscent of npm and node modules, include node sources.

Use this official command to delete the node, node_modules folder:

$ curl -ksO
$ chmod +x ./
$ ./
$ rm

2. Homebrew

The Homebrew methodology is without doubt one of the best methods of putting in and uninstalling node. If you happen to’re utilizing the brew set up node, simply use the next command:

$ brew uninstall node

3. Node Model Supervisor(NVM)

The Node Model Supervisor (NVM) is sort of as easy to make use of as Homebrew. You may set up a number of node variations in your system to mean you can migrate simply from one model to the subsequent.

Lastly, if you’re finished, you may most likely need to eliminate one of many variations. You are able to do this rapidly:

$ nvm uninstall <model>

For instance:

$ nvm uninstall v16.0.0.1


You’ve got put in Node.js, npm efficiently and checked the setup utilizing a easy program. Now you can use it to construct functions on the consumer or on the server.

You’ve got additionally seen how you can set up Node.js by way of homebrew, most likely the most well-liked macOS package deal supervisor.

Nevertheless, Node Model Supervisor is the quickest approach to set up Node.js. This supplies extra management and flexibility in adopting varied variations of Node.js, which can be wanted when you change between totally different initiatives based mostly in your wants.

Supply hyperlink

Leave a Reply

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

Check Also

Tesla will settle for bitcoin when miners use clear vitality

Elon Musk, the CEO of Tesla. Christophe Gateau/image alliance by way of Getty Pictures Tes…