How To Install Node Js In Windows 8
To start building your Node.js applications, the starting time step is the installation of the node.js framework. The Node.js framework is available for a diverseness of operating systems right from Windows to Ubuntu and Os X. Once the Node.js framework is installed, yous tin start edifice your showtime Node.js applications.
Node.js also has the ability to embedded external functionality or extended functionality by making apply of custom modules. These modules accept to be installed separately. An example of a module is the MongoDB module which allows y'all to piece of 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 10/8/7
- Running your starting time "Hello World" application in Node.js
How to Install Node.js on Windows
The first footstep in using Node.js is the installation of the Node.js libraries on the customer system. 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 example, we are going to Download Node.js on Windows with the 32-bit setup files.
Step 2) Run the installation
Double click on the downloaded .msi file to start the installation.
Click the Run button on the first screen to begin the installation.
Stride 3) Continue with the installation steps
In the next screen, click the "Next" button to go along with the installation
Step 4) Take the terms and conditions
In the next screen, Accept the license agreement and click on the Next push button.
Stride 5) Prepare the path
In the next screen, choose the location where Node.js needs to be installed so click on the Side by side button.
i. First, enter the file location for the installation of Node.js. This is where the files for Node.js will be stored subsequently the installation.
ii. Click on the Next button to keep ahead with the installation.
Step 6) Select the default components to be installed
Accept the default components and click on the Next push button.
Step 7) First the installation
In the next screen, click the Install button to start installing Node.js on Windows.
Step 8) Complete the installation
Click the Finish push to complete the installation.
Windows is now recommending that developers use Node.js with WSL2(the Windows subsystem for Linux)
How to Install NPM on Windows 10/8/7
The other mode to install Node.js on any client machine is to use a "package managing director."
On Windows, the NPM (Node Parcel Manager) download is known as Chocolatey. It was designed to be a decentralized framework for quickly installing applications and tools that y'all need.
For installing NPM on Windows via Chocolatey, the following 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 first pace 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 beneath 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 Bypass -Command "iex ((new-object moisture.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && Prepare PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
Pace 2) The next stride is to install Node.js to your local car using the Chocolatey, package director. This tin can be done past running the below control in the command prompt.
cinst nodejs install
If the installation is successful, you will get the message of the successful installation of Node.js.
Note: If y'all get an fault like "C:\ProgramData\chocolatey\lib\libreoffice\tools\chocolateyInstall.ps1" Then manually create the folder in the path
Running your first How-do-you-do World awarding in Node.js
Once you have Node.js download and installed on your computer, let'due south try to display "Hello World" in a web browser.
Create file Node.js with file name firstprogram.js
var http = crave('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Blazon': 'text/html'}); res.end('How-do-you-do World!'); }).mind(8080);
Code Explanation:
- The bones functionality of the "crave" function is that it reads a JavaScript file, executes the file, and then gain to return an object. Using this object, one can then use the diverse functionalities available in the module called by the crave function. So in our case, since we want to utilize the functionality of HTTP and we are using the require(http) command.
- In this 2nd line of code, we are creating a server application which is based on a simple function. This part is called, whenever a request is fabricated to our server application.
- When a request is received, we are asking our function to return a "Hello Globe" response to the client. The writeHead function is used to transport header data to the client, and while the end function will shut the connection to the client.
- Nosotros are and so using the server.listen function to make our server application listen to client requests on port no 8080. You can specify whatever available port over here.
Executing the lawmaking
- Salvage the file on your computer: C:\Users\Your Proper noun\ firstprogram.js
- In the command prompt, navigate to the folder where the file is stored. Enter the command Node firstprogram.js
- Now, your computer works as a server! If anyone tries to access your computer on port 8080, they will get a "How-do-you-do World!" message in render!
- Start your net browser, and type in the accost: http://localhost:8080
OutPut
Summary
- We take seen the installation of Node.js via the MSI installation module, which is bachelor 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 also be installed via a package manager. The package managing director for windows is known every bit Chocolatey. By running some uncomplicated commands in the control prompt, the Chocolatey package manager automatically downloads the necessary files and then installs them on the client machine.
- A simple Node.js application consists of creating a server which listens on a particular port. When a request comes to the server, the server automatically sends a 'Hello World' response to the customer.
Source: https://www.guru99.com/download-install-node-js.html
Posted by: keegansuching.blogspot.com
0 Response to "How To Install Node Js In Windows 8"
Post a Comment