Node.jsでHello World

(20)
http://www.tohoho-web.com/ex/nodejs.html

apt update
apt install nodejs
apt install npm
update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

node --version

vim hello.js

console.log("Hello world!");


node hello.js

vim web.js

var http = require('http');
var server = http.createServer(function(req, res) {
res.write("Hello world!\n");
res.end();
}).listen(8080);

node web.js

 

(10)

apt update
apt install nodejs
apt install npm
update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

node --version

vim hello.js

console.log("Hello world!");


node hello.js

vim web.js

var http = require('http');
var server = http.createServer(function(req, res) {
res.write("Hello world!\n");
res.end();
}).listen(8080);

node web.js

 

(8)

dnf -y install epel-release
dnf -y install nodejs
dnf -y install npm

node --version

vim hello.js

console.log("Hello world!");


node hello.js

vim web.js

var http = require('http');
var server = http.createServer(function(req, res) {
res.write("Hello world!\n");
res.end();
}).listen(8080);

node web.js

 

 

(2019)

https://nodejs.org/en/download/

node --version

notepad hello.js

console.log("Hello world!");


node hello.js


notepad web.js

var http = require('http');
var server = http.createServer(function(req, res) {
res.write("Hello world!\n");
res.end();
}).listen(8080);

node web.js