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