Install Node.js on CentOS 7

Install Node.js dan NPM pada centos 7

  • Tambahkan repository nodesource
curl -sL | sudo bash -
  • Install Node.js dan NPM
yum install nodejs -y
  • Cek versi node.js dan npm
node -v

npm -v

  • Jika ada error saat installasi Node.js, error seperti berikut:
[Errno 14] HTTP/HTTPS Error 404
[Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 403"
[Errno 14] Error 60 - It was impossible to connect to the CentOS servers
  • Lakukan clear cache system dan lakukan update repository fast
yum clean all && yum makecache fast

  • Tes aplikasi node.js dengan buat file hello.js (nano hello.js)
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(8080, '');
console.log('Server running at');
  • Jalankan aplikasi hello.js
node hello.js
Server running at
  • Test dengan curl pada new terminal atau browser
curl http://localhost:8080

Hello World


A system administrator with skills in system administration, virtualization, linux, windows, networking, cloud computing, container, etc.