Ubuntu 24.04 Node.js 18 をインストールする方法

環境
Ubuntu 24.04

Node.js 18 のインストールを行います
# apt -y install nodejs npm

Nodeのバージョンを確認します
# node -v
v18.19.1

テストスクリプトを作成します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# cat > test01.js <<'EOF'
var http = require('http');
var server = http.createServer(function(req, res) {
res.write("Hello, This is the Node.js テスト!\n");
res.end();
}).listen(8080);
EOF
# cat > test01.js <<'EOF' var http = require('http'); var server = http.createServer(function(req, res) { res.write("Hello, This is the Node.js テスト!\n"); res.end(); }).listen(8080); EOF
# cat > test01.js <<'EOF' 
var http = require('http');
var server = http.createServer(function(req, res) {
  res.write("Hello, This is the Node.js テスト!\n");
  res.end();
}).listen(8080);
EOF

動作確認
# node test01.js &
# curl localhost:8080

IT

Posted by arkgame