Node JS Tutorial - Installation
In this tutorial, we will learn how to install and create a Node JS app. Node.js is a powerful JavaScript-based platform built on Google Chrome's JavaScript V8 Engine, used to develop I/O intensive web applications such as video streaming sites, single-page applications, and other web applications.
Node.js is open source, completely free, and used by thousands of developers around the world. Now, let's install Node JS.
Downloading and Installing Node JS
Go to the Node.js website and download the Node.js setup file. After downloading the Node.js executable file, execute the setup file. To confirm whether Node.js is installed or not, go to the command prompt and run the following command:
node –version
After running this command, it will show the installed Node.js version.
Creating a New Node JS Project
Now, let's create our first Node JS project. Create a new folder, for example, "nodespro". Open the folder and open the command prompt. Inside the command prompt, type:
npm init
After this, it will ask for package name, version, entry point, and some other details. Read the instructions and enter the valid values one by one as follows:
- Package name: nodejspro
- Version: 1
- Description: my first nodejs project
- Entry point: index.js
- Text command: blank
- Git repository: blank
- Keywords: blank
- Author: Surfside Media
- Licence: blank
Now, press "y". Alright, the Node JS project is initialized.
Creating the index.js File
Open the project in Visual Studio Code. Click on "Open Folder" and choose the project "nodejs". You can see the package.json file. Now, create a new file called index.js. Inside this file, type:
console.log("print Welcome to node js");
Now, save the file.
Running the Node JS App
Now, run the Node JS app. Go to the command prompt and type:
node index.js
It will show "Welcome to Node JS" on the console.
In this way, you can install and create a new Node JS app.