[b]1、在官网下载nodejs,选择左边的。[/b]
[img]http://files.jb51.net/file_images/article/201612/2016120616010319.png[/img]
[b]2、选择文件右击点击extract here进行解压[/b]
[img]http://files.jb51.net/file_images/article/201612/2016120616010320.png[/img]
[b]3、进入bin目录,右击选择properties,解压文件可以随意放在系统里一个位置。复制location里的路径[/b]
[img]http://files.jb51.net/file_images/article/201612/2016120616010321.png[/img]
[img]http://files.jb51.net/file_images/article/201612/2016120616010422.png[/img]
[b]4、添加路径 进入.bashrc文件,在末尾处添加步骤三的
location里的路径。[/b]
[img]http://files.jb51.net/file_images/article/201612/2016120616010423.png[/img]
[img]http://files.jb51.net/file_images/article/201612/2016120616010424.png[/img]
[b]6、在终端输入source .bashrc按回车键,再输出路径:echo $PATH检查路径是否已经添加成功[/b]
[img]http://files.jb51.net/file_images/article/201612/2016120616010425.png[/img]
[b]7、检测是否安装nodejs成功。在js文件目录下点击右键,再点击open in terminal,进入终端,[/b][b]输入node 文件名(我安装时文件名为qishuixian.js) [/b]
[code]consloe.log("1111")[/code]
[img]http://files.jb51.net/file_images/article/201612/2016120616010426.png[/img]
[b] [img]http://files.jb51.net/file_images/article/201612/2016120616010427.png[/img]
[/b]
[b]8、在浏览器测试:server.js源码:[/b]
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200,
{'Content-Type':'text/html;charset=utf-8'});
if(request.url!=="/favicon.ico"){
console.log('访问');
response.write('hello,world');
response.end('你好,世界');
}
}).listen(8000); console.log('Server running at http://127.0.0.1:8000/');
[img]http://files.jb51.net/file_images/article/201612/2016120616010428.png[/img]
[img]http://files.jb51.net/file_images/article/201612/2016120616010429.png[/img]
以上所述是小编给大家介绍的Linux环境下nodejs的安装图文教程,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对编程素材网网站的支持!