centos6安装nodejs

前端之家收集整理的这篇文章主要介绍了centos6安装nodejs前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

wget -c https://nodejs.org/dist/v8.9.2/node-v8.9.2-linux-x64.tar.xz

tar xvJf node-v8.9.2-linux-x64.tar.xz

vim /etc/profile

export PATH=/root/node-v8.9.2-linux-x64/bin:$PATH

node -v

参考官网写个app.js启动JS

const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req,res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type','text/plain');
  res.end('Hello World\n');
});

server.listen(port,hostname,() => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

测试curl http://127.0.0.1:3000

原文链接:https://www.f2er.com/centos/375080.html

猜你在找的CentOS相关文章