Contact Us
Node JS, Tech

How to Install Node JS

NodeJS is an open source, cross-platform, runtime Javascript environment that executes the code outside the web browser. In this tutorial, you will learn how to install node JS and get started.

With the power and simplicity of Javascript, NodeJS became one of the most widely used languages to write server-side programming scripts.

Intro – Install Node JS

Follow these instructions to install NodeJS on your system and set up your development environment.

  1. Download the latest LTS of NodeJS from this link: https://nodejs.org/en/download/
  2. Run the installer for the OS of your choice. This installer comes with the node package manager(npm)
  3. NPM helps you in managing all the node modules, packages, libraries, and frameworks.
  4. Once the installation is complete, open your terminal (on mac) or cmd (on windows) and type the following command, and you should see a result like this :
$ node
> hi = "Hello, World"
'hello, World'

Getting Started

Now that our NodeJS environment is up and running, let us go ahead and create our first NodeJS application. We can now, actually see the working and usefulness of NPM. To find the version of the npm you are using, try the following command on your terminal.

$ npm -v

Now that both NodeJS and npm are working, we can start by initialising our first project.

$ mkdir myfirstnodeapp && cd myfirstnodeapp
$ npm init

The npm init command will initialise the NodeJS application. Here, you can add the name of the app, version, description, entry point, author, license, etc. You can use the default values by just hitting enter and finally it will show the entered details. To confirm, you can type yes and hit enter. This will create a package.json file in the folder.

Now, open the myfirstnodeapp folder using your favorite IDE or Text Editor. I personally prefer Sublime Text. Create a new file index.js and type the following code :

console.log("Hello, World!");
console.log("This is my first NodeJS App!!!");

We are almost done. This code will just print the text on the console. Now we can add the start scripts to this project.

Open the package.json file in your text editor and add this following line in your scripts section.

"start" : "node index.js"

Once you have added this start script, your package.json file should look something like this:

{
"name": "myfirstnodeapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"author": "yourname",
"license": "ISC"
}

This start script will help you run your app using the npm start command. Let’s test it out now! Open the myfirstnodeapp folder on your terminal and run this command :

$ cd myfirstnodeapp
$ npm start

Yes! We did it! Our first NodeJS app works flawlessly! Now that you have learnt how to install node JS, we will take on more complex tasks in the coming posts. For now, kudos to you!

Leave a Reply

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

Privacy Settings
We use cookies to enhance your experience while using our website. If you are using our Services via a browser you can restrict, block or remove cookies through your web browser settings. We also use content and scripts from third parties that may use tracking technologies. You can selectively provide your consent below to allow such third party embeds. For complete information about the cookies we use, data we collect and how we process them, please check our Privacy Policy
Youtube
Consent to display content from Youtube
Vimeo
Consent to display content from Vimeo
Google Maps
Consent to display content from Google
Spotify
Consent to display content from Spotify
Sound Cloud
Consent to display content from Sound
Open chat
1
🎉 Get a free quote now!
Hello, how can we help you! 👾