Install NodeJS on Mac OS

To install NodeJS on a Mac the first thing you have to do is download Brew package manager for mac. Though you can install NodeJS via other methods but doing it with Brew is the easiest and least error prone method

1. Install Brew on your mac if you dont have it already. Open the terminal app and paste the below command (make sure you have the password for the user)

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2. Now the Brew package manager is installed. Open terminal and type below command

brew install node

3. Check Versions of Node and NPM

node -v
npm -v

4. Create a Demo Web server and Check. Open terminal and type below

vim demo_server.js
-- Paste below Code in the file --
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Welcome To EasyOraDBA');
}).listen(3005, "127.0.0.1");
console.log('Server is running at http://127.0.0.1:3005/');
 
node demo_server.js

— Now open a Web browser and paste the URL http://127.0.0.1:3005/ And voila you have a NodeJS Web Server running —

Category: Uncategorized

Tags:

Leave a Reply

Article by: Shadab Mohammad