V tomto článku si heslovitě popíšeme instalaci Node.js, npm (správce balíčků Node.js), Socket.IO, React a Express. Dále si ukážeme základní použití Node.js pro úplné začátečníky.
Instalace Node.js
Instalace npm
Instalace Socket.IO
Instalace React
Instalace Express
Vytvoříme např. node.js skript app.js:
A provedeme jeho spuštění:
Když teď v prohlížeči otevřeme http://localhost:5000, tak se nám zobrazí "Hello World!".
Doinstalováním balíčku screen (pro linux) a modulu nodemon můžeme zajistit automatický restart node.js aplikací:
A konečně provedeme nahození node.js aplikace v novém sezení (screen) pomocí nodemon:
Dáme zkratku ctrl+a+d a tím nám node.js aplikace app.js poběží na pozadí...
8
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 ...
Instalace
Instalace Node.js
apt install nodejs
Instalace npm
apt install npm
Instalace Socket.IO
npm install socket.io
Instalace React
npm install react
Instalace Express
npm install express
Použití Node.js
Vytvoříme např. node.js skript app.js:
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');
A provedeme jeho spuštění:
nodejs app.js
Když teď v prohlížeči otevřeme http://localhost:5000, tak se nám zobrazí "Hello World!".
Autostart node.js aplikací
Doinstalováním balíčku screen (pro linux) a modulu nodemon můžeme zajistit automatický restart node.js aplikací:
apt install screen
npm install nodemon
A konečně provedeme nahození node.js aplikace v novém sezení (screen) pomocí nodemon:
screen
nodemon app.js
Dáme zkratku ctrl+a+d a tím nám node.js aplikace app.js poběží na pozadí...
8
The English language is translated by machine - the translator can modify eg cited codes = it is better to use codes from the Czech original.
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
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 ...