当前位置首页 > Debian知识

node(一)安装nodejs最新版到debian,ubuntu,mint系统

阅读次数:232 次  来源:admin  发布时间:

从官网得到,测试可以使用,本机为linux mint18 官网原文链接在此 // 直接使用sudo apt install nodejs安装的版本较老,而且命令必须使用nodejs // 使用下面的方法,终端输入node即可使用,而且是最新版本

//     安装4.x版本稳定版,现在为v4.4.7LTS
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
//     安装6.x开发版,现在为v6.0.3current
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
//     Optional: install build tools
 
//     To compile and install native addons from npm you may also need to install build tools:
sudo apt-get install -y build-essential
//     测试是否安装成功:
//     新建文件server.js
var http = require('http');
 
http.createServer(function (request, response) {
 
// 发送 HTTP 头部 
// HTTP 状态值: 200 : OK
// 内容类型: text/plain
response.writeHead(200, {'Content-Type': 'text/plain'});
 
// 发送响应数据 "Hello World"
response.end('Hello World\n');
}).listen(8888);
 
// 终端打印如下信息
console.log('Server running at http://127.0.0.1:8888/');
使用node --version,查看版本号 v4.4.7 在server.js文件目录下输入node server.js 开启服务 输入node server.js 显示Server running at http://127.0.0.1:8888/ 保持终端不关闭 在浏览器端 访问http://127.0.0.1:8888/ 或 localhost:8888 即可 显示hello world
上一篇:IISServerFarms入门
下一篇:Centos搭建SVN服务器