1. 到http://nodejs.org/下载并编译,支持Linux、Mac,也支持windows下的Cygwin。
Windows:
1. windows下 要先安装 cygwin
安装步骤:
-
- 下载 setup.exe
from www.cygwin.com.
- 运行setup.exe.
- 选择下一步
- 下载 setup.exe
4.选择 "Install from Internet" 并点击 下一步.
5.Enter preferred installation (Root) directory and click next.
6. Enter a temporary installation directory and click next.
7. Select "Direct Connection" and click next.
8.Select a download site and click next.
9. Select the packages you want to install and click next.
Packages you may want to install include:
Devel
- gcc-g++: C++ compiler
- gcc-mingw-g++: Mingw32 support headers and libraries for GCC C++
- gcc4-g++: G++ subpackage
- git: Fast Version Control System – core files
- make: The GNU version of the ‘make’ utility
- openssl-devel: The OpenSSL development environment
- pkg-config: A utility used to retrieve information about installed libraries
- zlib-devel: The zlib compression/decompression library (development)
Editor
- vim: Vi IMproved – enhanced vi editor
Python
- 全部
Web 分类
- wget: Utility to retrieve files from the WWW via HTTP and FTP
- curl: Multi-protocol file transfer command-line tool
Please note sometimes you may get a download incomplete and the setup application will return to step 8. Simply select another server and continue the installation process.
10.Once the installation is complete, click Finish and continue with the Setup section.
Setup Windows Environment Variables:
2.安装Node.js
打开cygwin 终端
git clone https://github.com/joyent/node.git
cd node
./configure
make
sudo make install
到此安装成功。
3.测试node.js
创建hello.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 目录下 或其它目录
打开浏览器: http://127.0.0.1:8124/
看到如下结果表明你已经成功安装node.js