博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
node(一)安装nodejs最新版到debian,ubuntu,mint系统
阅读量:7240 次
发布时间:2019-06-29

本文共 1159 字,大约阅读时间需要 3 分钟。

从官网得到,测试可以使用,本机为linux mint18
官网原文
//     直接使用sudo apt install nodejs安装的版本较老,而且命令必须使用nodejs
//     使用下面的方法,终端输入node即可使用,而且是最新版本
//     安装4.x版本稳定版,现在为v4.4.7LTScurl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -sudo apt-get install -y nodejs
//     安装6.x开发版,现在为v6.0.3currentcurl -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.jsvar http = require('http'); http.createServer(function (request, response) { // 发送 HTTP 头部 // HTTP 状态值: 200 : OK// 内容类型: text/plainresponse.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
 
 

转载于:https://www.cnblogs.com/iamhenanese/p/5686608.html

你可能感兴趣的文章
今天看见了一个有意思的题目-----请实现鼠标点击页面中的任意标签,alert该标签的名字...
查看>>
Windows 7 Professional安装多语言包
查看>>
SOC-training image镜像内核文件(DE1-soc软件实验”hello_word")
查看>>
使用 Apache Commons CLI 开发命令行工具示例
查看>>
第十三章 接口
查看>>
进度条9
查看>>
robotframework自动化测试之测试数据
查看>>
[NOI2008]志愿者招募
查看>>
同一个闭区间上有界变差函数的和与积都是有界变差函数
查看>>
Elementary Methods in Number Theory Exercise 1.5.10
查看>>
「陶哲軒實分析」 習題 3.5.1
查看>>
大聊Python----协程
查看>>
nginx.pid-nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or direc
查看>>
在CentOS上配置SAMBA共享目录(转载)
查看>>
Linux之samba搭建
查看>>
第十三周学习笔记
查看>>
ZOJ 2770 Burn the Linked Camp 差分约束 (转)
查看>>
Python随笔1
查看>>
Ubuntu16.04搭建Postfix作为SMTP服务器
查看>>
Linux——网络端口的状态netstat、ifconfig
查看>>