How To Run Node Js In Windows 7
To kickoff building your Node.js applications, the first step is the installation of the node.js framework. The Node.js framework is bachelor for a diverseness of operating systems right from Windows to Ubuntu and Bone X. Once the Node.js framework is installed, you tin can start building your get-go Node.js applications.
Node.js also has the ability to embedded external functionality or extended functionality by making utilise of custom modules. These modules have to be installed separately. An instance of a module is the MongoDB module which allows you to piece of work with MongoDB databases from your Node.js awarding.
In this tutorial, you volition learn-
- How to Download & Install Node.js on Windows
- How to Install NPM on Windows 10/8/7
- Running your first "Hullo World" application in Node.js
How to Install Node.js on Windows
The first step in using Node.js is the installation of the Node.js libraries on the client arrangement. Below are the steps to download and install Node.js in Windows:
Step i) Download Node.js Installer for Windows
Go to the site https://nodejs.org/en/download/ and download the necessary binary files.
In our example, nosotros 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 commencement screen to begin the installation.
Step three) Continue with the installation steps
In the side by side screen, click the "Next" button to continue with the installation
Step 4) Accept the terms and conditions
In the next screen, Take the license agreement and click on the Adjacent button.
Step 5) Ready the path
In the adjacent screen, choose the location where Node.js needs to be installed and then click on the Next button.
i. 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 Next button to keep ahead with the installation.
Pace vi) Select the default components to exist installed
Accept the default components and click on the Next button.
Step 7) Start the installation
In the next screen, click the Install button to start installing Node.js on Windows.
Step eight) Complete the installation
Click the Finish button 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/vii
The other fashion to install Node.js on whatever client machine is to use a "package director."
On Windows, the NPM (Node Package Manager) download is known as Chocolatey. It was designed to be a decentralized framework for rapidly installing applications and tools that you need.
For installing NPM on Windows via Chocolatey, the following steps need to exist 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 footstep is to run the below control in the command prompt windows. This control is taken from the Chocolatey spider web site and is the standard control for installing Node.js via Chocolatey.
- The below command is a PowerShell control which calls the remote PowerShell script on the Chocolatey website. This control needs to be run in a PowerShell control 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
Step 2) The side by side step is to install Node.js to your local car using the Chocolatey, package manager. This can be done past running the beneath command in the command prompt.
cinst nodejs install
If the installation is successful, you will become the message of the successful installation of Node.js.
Note: If you get an error similar "C:\ProgramData\chocolatey\lib\libreoffice\tools\chocolateyInstall.ps1" Then manually create the folder in the path
Running your beginning How-do-you-do World application in Node.js
Once yous have Node.js download and installed on your computer, let'south try to brandish "Hello World" in a web browser.
Create file Node.js with file name firstprogram.js
var http = require('http'); http.createServer(part (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.stop('Hello Globe!'); }).heed(8080); Code Explanation:
- The basic functionality of the "require" part is that it reads a JavaScript file, executes the file, so proceeds to return an object. Using this object, ane tin and then use the various functionalities available in the module chosen by the require function. And so in our case, since we want to use the functionality of HTTP and nosotros are using the crave(http) command.
- In this 2nd line of code, nosotros are creating a server application which is based on a simple function. This function is chosen, whenever a request is made to our server awarding.
- When a asking is received, we are request our role to render a "Hello World" response to the client. The writeHead part is used to send header data to the client, and while the terminate function volition shut the connection to the customer.
- Nosotros are then using the server.mind function to make our server application listen to client requests on port no 8080. You can specify any available port over hither.
Executing the code
- Save the file on your estimator: C:\Users\Your Name\ firstprogram.js
- In the control prompt, navigate to the folder where the file is stored. Enter the command Node firstprogram.js
- Now, your computer works every bit a server! If anyone tries to access your figurer on port 8080, they will go a "Hello World!" message in return!
- Start your internet browser, and type in the accost: http://localhost:8080
OutPut
Summary
- We accept 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 client.
- Node.js tin besides be installed via a package managing director. The bundle manager for windows is known as Chocolatey. By running some simple commands in the command prompt, the Chocolatey package managing director automatically downloads the necessary files and and so installs them on the customer car.
- A uncomplicated 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 client.
Source: https://www.guru99.com/download-install-node-js.html
Posted by: duppstadtvoiceselen.blogspot.com

0 Response to "How To Run Node Js In Windows 7"
Post a Comment