Rocky Linux 8.4 にnode.js 12 をインストールする
1.有効Node.jsのバージョンを確認
[root@arkgame ~]# dnf module list nodejs
Rocky Linux 8 - AppStream
Name Stream Profiles Summary
nodejs 10 [d] common [d], development, minimal, s2i Javascript runtime
nodejs 12 common [d], development, minimal, s2i Javascript runtime
nodejs 14 common [d], development, minimal, s2i Javascript runtime
ヒント: [d]efault, [e]nabled, [x]disabled, [i]nstalled
[root@arkgame ~]# dnf module list nodejs
Rocky Linux 8 - AppStream
Name Stream Profiles Summary
nodejs 10 [d] common [d], development, minimal, s2i Javascript runtime
nodejs 12 common [d], development, minimal, s2i Javascript runtime
nodejs 14 common [d], development, minimal, s2i Javascript runtime
ヒント: [d]efault, [e]nabled, [x]disabled, [i]nstalled
[root@arkgame ~]# dnf module list nodejs Rocky Linux 8 - AppStream Name Stream Profiles Summary nodejs 10 [d] common [d], development, minimal, s2i Javascript runtime nodejs 12 common [d], development, minimal, s2i Javascript runtime nodejs 14 common [d], development, minimal, s2i Javascript runtime ヒント: [d]efault, [e]nabled, [x]disabled, [i]nstalled
2.他バージョンが有効な場合、nodejsをリセットして有効バージョンをスイッチ
[root@arkgame ~]# dnf module -y reset nodejs
[root@arkgame ~]# dnf module -y enable nodejs:12
[root@arkgame ~]# dnf module -y reset nodejs
[root@arkgame ~]# dnf module -y enable nodejs:12
[root@arkgame ~]# dnf module -y reset nodejs [root@arkgame ~]# dnf module -y enable nodejs:12
3.node.js 12を指定してインストール
[root@arkgame ~]# dnf module -y install nodejs:12/common
4.バージョンの確認
[root@arkgame ~]# node -v
v12.22.5
5.動作確認
[root@arkgame ~]# vi test.js
var http = require('http');
var server = http.createServer(function(req, res) {
res.write("study skill in nodejs 12\n");
res.end();
}).listen(8080)
テストスクリプトを実行
[root@arkgame ~]# node test.js &
[1] 10029
[root@arkgame ~]# curl 127.0.0.1:8080
study skill in nodejs 12
[root@arkgame ~]# kill 10029
[root@arkgame ~]# vi test.js
var http = require('http');
var server = http.createServer(function(req, res) {
res.write("study skill in nodejs 12\n");
res.end();
}).listen(8080)
テストスクリプトを実行
[root@arkgame ~]# node test.js &
[1] 10029
[root@arkgame ~]# curl 127.0.0.1:8080
study skill in nodejs 12
[root@arkgame ~]# kill 10029
[root@arkgame ~]# vi test.js var http = require('http'); var server = http.createServer(function(req, res) { res.write("study skill in nodejs 12\n"); res.end(); }).listen(8080) テストスクリプトを実行 [root@arkgame ~]# node test.js & [1] 10029 [root@arkgame ~]# curl 127.0.0.1:8080 study skill in nodejs 12 [root@arkgame ~]# kill 10029