当前位置: 移动技术网 > 网络运营>服务器>Linux > Linux环境下nodejs的安装图文教程

Linux环境下nodejs的安装图文教程

2019年06月03日  | 移动技术网网络运营  | 我要评论

1、在官网下载nodejs,选择左边的。

2、选择文件右击点击extract here进行解压

3、进入bin目录,右击选择properties,解压文件可以随意放在系统里一个位置。复制location里的路径

4、添加路径 进入.bashrc文件,在末尾处添加步骤三的location里的路径。




6、在终端输入source .bashrc按回车键,再输出路径:echo $path检查路径是否已经添加成功


7、检测是否安装nodejs成功。在js文件目录下点击右键,再点击open in terminal,进入终端,输入node 文件名(我安装时文件名为qishuixian.js) 

consloe.log("1111")

8、在浏览器测试:server.js源码:

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/'); 




以上所述是小编给大家介绍的linux环境下nodejs的安装图文教程,希望对大家有所帮助

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网