Install and use Node.js, npm, Socket.IO, React, Express
In this article, we will briefly describe the installation of Node.js , npm (Package Manager Node.js), Socket.IO , React and Express . Below we will show you the basic usage of Node.js for beginners.
Installation Node.js
Installation npm
Installation Socket.IO
Installation React
Installation Express
For example, create an app.js node.js script:
And we'll run it:
Now when we open http://localhost:5000 in the browser, we see "Hello World!".
By installing the screen package (for linux) and the nodemon module, we can automatically restart the node.js applications:
Finally, we roll the node.js application in the new screen using nodemon:
Put the shortcut ctrl+a+d to make the app.js node.js run in the background ...
Installation
Installation Node.js
apt install nodejs
Installation npm
apt install npm
Installation Socket.IO
npm install socket.io
Installation React
npm install react
Installation Express
npm install express
Example of using Node.js
For example, create an app.js node.js script:
vim app.js
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World!');
}).listen(5000);
console.log('We up at http://localhost:5000');
And we'll run it:
nodejs app.js
Now when we open http://localhost:5000 in the browser, we see "Hello World!".
Autostart node.js apps
By installing the screen package (for linux) and the nodemon module, we can automatically restart the node.js applications:
apt install screen
npm install nodemon
Finally, we roll the node.js application in the new screen using nodemon:
screen
nodemon app.js
Put the shortcut ctrl+a+d to make the app.js node.js run in the background ...