Installing node.js on Mac OSX
I recently installed node.js on a Mac running OSX 10.7.2 and these were the steps I followed at the command line. Â Git and Xcode were already installed on the machine so this assumes they are already present.
- git clone git://github.com/ry/node.git
- cd node
- ./configure
- make
- sudo make install
You can test that node is installed by running a simple program such as:
var http = require('http'); http.createServer(function (request, response) { Â response.writeHead(200, {'Content-Type': 'text/plain'}); Â response.end('Node.js has arrived.\n'); }).listen(1337, "127.0.0.1"); console.log('Up and running at http://127.0.0.1:1337/');
You can run this code by saving it as something like testing-node.js and then entering the command:
node testin-node.js
That’s it. Node.js is now up and running on port 1337 !
PS: stop the server with ctrl + c