腾讯云服务器配置node环境
1:更新现有包
sudo apt-get update
2:安装依赖
sudo apt-get install vim openssl build-essential libssl-dev wget curl
3:安装nvm,管理服务器上的node版本
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash<br />或者<br />wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash<br />//安装结束,重新打开一个命令行窗口,输入nvm,查看nvm的命令<br />nvm<br />
4:安装指定node版本,并且在当前应用下指定node版本
nvm install v8.11.1 nvm use v8.11.1 nvm alias default v8.11.1<br />node -v<br />npm -v<br />配置淘宝镜像<br />npm install -g cnpm --registry=https://registry.npm.taobao.org
5:新建node启动文件进行测试
sudo vi app.js const http = require('http') http.createServer(function(req, res){ res.writeHead(200, {'Content-Type': 'text/plain'}) res.end('hello world') }).listen(8081) console.log('server runing on http://139.199.184.174:8081') // 保存启动app.js Esc => shift + : => wq => enter<br /><br />node app.js
打开139.199.184.174:8081即可正常访问
相关推荐
wyzxzws 2020-06-11
sunnnyduan 2020-05-31
boneix 2020-10-21
seanzed 2020-10-15
ifconfig 2020-10-14
学留痕 2020-09-20
往后余生 2020-09-17
kka 2020-09-14
redis 2020-09-07
lzccheng 2020-09-06
soyo 2020-08-31
stonerkuang 2020-08-18
LxyPython 2020-08-17
raksmart0 2020-08-17
Lzs 2020-08-14
MrHaoNan 2020-07-31
80530895 2020-07-05
lengyu0 2020-06-28