码迷,mamicode.com
首页 > 其他好文 > 详细

腾讯云服务器配置node环境

时间:2018-05-16 19:45:46      阅读:990      评论:0      收藏:0      [点我收藏+]

标签:--   dev   world   type   raw   update   nod   bsp   github   

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
或者
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash
//安装结束,重新打开一个命令行窗口,输入nvm,查看nvm的命令
nvm

4:安装指定node版本,并且在当前应用下指定node版本

nvm install v8.11.1
nvm use v8.11.1
nvm alias default v8.11.1
node -v
npm -v
配置淘宝镜像
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

node app.js

  打开139.199.184.174:8081即可正常访问

 

腾讯云服务器配置node环境

标签:--   dev   world   type   raw   update   nod   bsp   github   

原文地址:https://www.cnblogs.com/sk-3/p/8866256.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!