AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL

Install Node.js


<< Previous Page
Nodejs tutorial
Next Page >>
Nodejs tutorial

Node.js Tutorial » Install Node.js

How do I install Node JS?

We strongly recommend using a Node version manager like nvm to install Node.js and npm. We do not recommend using a Node installer, since the Node installation process installs npm in a directory with local permissions and can cause permissions errors when you run npm packages globally.

To install Node.js, you can use an installer or binary package from the node.js website: Node JS Downloads.

Node.js allows us to generate high-efficiency web servers without the need for large configurations, and the application of the same language allows us to avoid separating the code between the application and the service. To create our first server, we need to follow these steps:

To download the latest version of npm, on the command line, run the following command:

npm install -g npm
Note: Node.js page has installation instructions for different operating systems as: Linux, Windows, Unix, Mac OS X, etc):

 

Simple Node.js server script

1. I installed Node.js (V.8) in the "E: / nodejs /" directory. For tests I created another directory called "test" in this directory.

2. Now in the "test" directory (E: / nodejs / test /) I created a file called "server.js" (you can use any name you want) and I added the following code: (Click on the code to select it):

//include the http module
const http = require('http');

//define constant for port
const port =8080;

//sets the server
const server = http.createServer((req, res)=> {
res.writeHead(200, {'Content-Type':'text/plain'});
res.write('Hi. How are you?');
res.end();
});

//pass the port to server to listen to
server.listen(port, ()=> {
console.log('Server running at //localhost:'+ port +'/');
});

The code tells the computer to type "Hi. How are you?" if someone (eg a web browser) accesses the computer through port 8080.

 

How do I install node js on Windows

3. Serverul Node.js trebuie sa fie pornit prin programul "Command Line Interface" de pe calulatorul tau. - Pentru a deschide interfata command line in windows, apasa butonul Start si scrie "cmd" in casuta search.

4. In the windows command line interface navigate to the directory that contains the Node.js application (E: nodejs /), then to start the "server.js" script type: "node test / server.js", and press Enter.

In the windows command line interface, node.js displays: "Server running at // localhost: 8080 /".

 

Node js install

- The computer now works as a server.

5. I open the browser and type in the access address: http: // localhost: 8080

 



node.js install: windows, ubuntu, npm, linux, ubuntu 20.04, older version windows, windows command line, express, centos, debian
How do I install Node JS?
Can I install node with npm?
What is npm I install?
How do I install node js on Windows 10?
Install Node.js - nodejs

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


0
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


CSS background color - opacity, gradient...
CSS flex - display: flex - CSS Flexbox L...
CSS border padding...
HTML text center horizontally and vertic...
HTML text input <input type="text"&g...
HTML link color...
How to Link CSS to HTML, external file n...
HTML link - hyperlink...
jQuery replace...
jQuery replaceClass...
jQuery click ()...
jQuery switchClass()...
jQuery draggable()...
jQuery HTML...
jQuery scroll smooth...
jQuery scroll()...
jQuery stop()...
jQuery animate()...
jQuery SlideToggle()...
jQuery slideDown()...