如何安装Node.js

发布时间:2020-07-12 02:57:12 作者:chenshengang
来源:网络 阅读:283

下面分别介绍在Mac, Ubuntu,Centos以及Windows下安装Node.js.

Mac

在Mac下,如果你喜欢用homebrew,那么只用一行就可以装好:

brew install node

否则,只能考虑手工安装了,步骤如下:

安装Xcode

安装git

运行下面的命令行编译node.js

git clone git://github.com/joyent/node.git

cd node

./configure

make

sudo make install


Ubuntu

安装依赖包

sudo apt-get install g++ curl libssl-dev apache2-utils

sudo apt-get install git-core

运行下面的命令行:

git clone git://github.com/joyent/node.git

cd node

./configure

make

sudo make install


Windows

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

安装cygwin

在cygwin的目录下,运行setup.exe安装下面列表中的包

devel → openssl

devel → g++-gcc

devel → make

python → python

devel → git

运行cygwin

运行下面的命令行:

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.js\n');

}).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

原文:http://www.ooso.net/archives/589

推荐阅读:
  1. node.js Linux下安装
  2. Node.js安装

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

node j %d

上一篇:ImSQL:海量数据,可信存储

下一篇:非线性视频编辑环境搭建

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》