Ubuntu 22.04にNode.js 12 をインストールする
環境
Ubuntu 22.04.1 LTS node v12.22.9 npm 8.5.1
操作方法
1.Node.js 12 をインストールします
# apt -y install nodejs npm
2.バージョンを確認します
# node -v v12.22.9
3.テストスクリプトを作成します
# cat > nodetest.js <<'EOF'
var http = require('http');
var server = http.createServer(function(req, res) {
res.write("Hello worl, This is the Node.js Simple Web Server!\n");
res.end();
}).listen(8080);
> EOF
4.動作確認
# node nodetest.js &
[1] 54120
# curl localhost:8080
Hello worl, This is the Node.js Simple Web Server!