How to install node. js on Mac and Windows


Mac

On the Mac, if you prefer homebrew, you can install it in one line:

The brew install node

Otherwise, you can only consider manual installation, as follows: Install Xcode Install git Run the following command line to compile node.js


git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install

Ubuntu Install dependency package

Sudo apt-get install g++ curl libssl-dev apache2-utils Sudo apt - get the install git - core

Run the following command line: The same code at the page code block index 0 Windows

To install node with cygwin, follow these steps: Install cygwin From the cygwin directory, run setup.exe to install the packages in the following list Devel - > openssl The devel - g + + - GCC The devel - make The python - python The devel - git Run cygwin Run the following command line: The same code at the page code block index 0 Centos


yum install gcc-c++ openssl-devel
wget --no-check-certificate https://github.com/ry/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!

Write a small program such as hello_node.js to verify that the installation is correct:


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/');

Run this code in node


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

Now, open http://127.0.0.1:8124/ with your browser and you should see a piece of good news.