How To Open Node Js Command Prompt In Windows
To start building your Node.js applications, the first pace is the installation of the node.js framework. The Node.js framework is available for a multifariousness of operating systems right from Windows to Ubuntu and OS 10. Once the Node.js framework is installed, you can start building your first Node.js applications.
Node.js also has the ability to embedded external functionality or extended functionality past making use of custom modules. These modules accept to be installed separately. An case of a module is the MongoDB module which allows you to work with MongoDB databases from your Node.js application.
In this tutorial, you will learn-
- How to Download & Install Node.js on Windows
- How to Install NPM on Windows ten/8/7
- Running your first "Hi World" application in Node.js
How to Install Node.js on Windows
The offset step in using Node.js is the installation of the Node.js libraries on the client organization. Below are the steps to download and install Node.js in Windows:
Pace 1) Download Node.js Installer for Windows
Get to the site https://nodejs.org/en/download/ and download the necessary binary files.
In our instance, we are going to Download Node.js on Windows with the 32-bit setup files.
Footstep 2) Run the installation
Double click on the downloaded .msi file to start the installation.
Click the Run push button on the offset screen to begin the installation.
Footstep 3) Continue with the installation steps
In the next screen, click the "Adjacent" button to continue with the installation
Step 4) Take the terms and conditions
In the adjacent screen, Accept the license agreement and click on the Next button.
Step 5) Prepare the path
In the side by side screen, choose the location where Node.js needs to exist installed and so click on the Next push.
1. First, enter the file location for the installation of Node.js. This is where the files for Node.js will be stored after the installation.
2. Click on the Adjacent push button to go on ahead with the installation.
Stride 6) Select the default components to be installed
Take the default components and click on the Next button.
Step 7) Start the installation
In the next screen, click the Install push button to get-go installing Node.js on Windows.
Stride 8) Consummate the installation
Click the Finish push button to complete the installation.
Windows is now recommending that developers utilize Node.js with WSL2(the Windows subsystem for Linux)
How to Install NPM on Windows 10/8/seven
The other way to install Node.js on any client car is to apply a "package manager."
On Windows, the NPM (Node Packet Manager) download is known as Chocolatey. It was designed to be a decentralized framework for chop-chop installing applications and tools that you need.
For installing NPM on Windows via Chocolatey, the post-obit steps need to be performed.
Step 1) Installing Chocolatey – The Chocolatey website (https://chocolatey.org/) has very clear instructions on how this framework needs to be installed.
- The starting time step is to run the beneath command in the command prompt windows. This command is taken from the Chocolatey web site and is the standard command for installing Node.js via Chocolatey.
- The below command is a PowerShell command which calls the remote PowerShell script on the Chocolatey website. This command needs to be run in a PowerShell command window.
- This PowerShell script does all the necessary work of downloading the required components and installing them accordingly.
@powershell -NoProfile -ExecutionPolicy Featherbed -Command "iex ((new-object wet.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
Stride 2) The side by side step is to install Node.js to your local car using the Chocolatey, package managing director. This tin be washed past running the below command in the command prompt.
cinst nodejs install
If the installation is successful, you will get the message of the successful installation of Node.js.
Annotation: If you get an error similar "C:\ProgramData\chocolatey\lib\libreoffice\tools\chocolateyInstall.ps1" Then manually create the folder in the path
Running your first Hello Earth application in Node.js
Once you accept Node.js download and installed on your figurer, let'due south try to display "Hullo World" in a spider web browser.
Create file Node.js with file proper name firstprogram.js
var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.end('Hi Globe!'); }).listen(8080); Code Explanation:
- The bones functionality of the "require" function is that it reads a JavaScript file, executes the file, and so proceeds to return an object. Using this object, one tin then use the diverse functionalities available in the module called by the require role. So in our case, since we want to utilise the functionality of HTTP and we are using the require(http) command.
- In this 2nd line of lawmaking, we are creating a server application which is based on a simple function. This function is called, whenever a request is fabricated to our server application.
- When a asking is received, we are request our office to return a "Howdy World" response to the client. The writeHead function is used to transport header information to the customer, and while the end part will close the connection to the customer.
- We are then using the server.listen function to make our server application listen to client requests on port no 8080. You can specify any available port over here.
Executing the lawmaking
- Relieve the file on your computer: C:\Users\Your Name\ firstprogram.js
- In the control prompt, navigate to the binder where the file is stored. Enter the control Node firstprogram.js
- At present, your computer works equally a server! If anyone tries to admission your computer on port 8080, they volition get a "Hullo World!" message in return!
- Start your internet browser, and type in the address: http://localhost:8080
OutPut
Summary
- We have seen the installation of Node.js via the MSI installation module, which is available on the Node.js website. This installation installs the necessary modules which are required to run a Node.js awarding on the customer.
- Node.js can besides be installed via a bundle manager. The package managing director for windows is known every bit Chocolatey. By running some simple commands in the command prompt, the Chocolatey parcel manager automatically downloads the necessary files and then installs them on the customer car.
- A simple Node.js application consists of creating a server which listens on a particular port. When a asking comes to the server, the server automatically sends a 'Hello World' response to the client.
Source: https://www.guru99.com/download-install-node-js.html
Posted by: merriweathermosed1997.blogspot.com

0 Response to "How To Open Node Js Command Prompt In Windows"
Post a Comment