如何安装Node.js

Windows

用cygwin来安装node,步骤如下:

    1. 安装cygwin
    2. 在cygwin的目录下,运行setup.exe安装下面列表中的包
      • devel → openssl
      • devel → g++-gcc
      • devel → make
      • python → python
      • devel → git
    3. 运行cygwin
    4. 运行下面的命令行:
      git clone git://github.com/joyent/node.git  cd node  ./configure  make  sudo make install

Centos

yum install gcc-c++ openssl-devel  wget --no-check-certificate https://github.com/joyent/node/tarball/v0.3.3  tar -xzvf ry-node-v0.3.3-0-g57544ba.tar.gz  cd ry-node-v0.3.3-0-g57544bac1  ./configure  make  make install

Hello Node.js!

写一段小程序例如hello_node.js来验证安装是否正确:

var http = require('http');  http.createServer(function (req, res) {    res.writeHead(200, {'Content-Type': 'text/plain'});    res.end('Hello Node.jsn');  }).listen(8124, "127.0.0.1");  console.log('Server running at http://127.0.0.1:8124/');

用node来运行这段代码

node hello_node.js  Server running at http://127.0.0.1:8124/

现在,用浏览器打开 http://127.0.0.1:8124/ , 应该能够看到一条好消息。

参考文档

How to Install Node.js

Update

  • 补充了在centos上安装Node.js的步骤 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值