Links
Xcode
Download and install Xcode from the Apple website. For Xcode 4.4 and above, install the Command Line Tools from the Xcode → Preferences menu, in the Downloads tab.
Installing Git
You can install Git via a package manager like Homebrew, or download an installer from the Git website.
Installing NVM
git clone git://github.com/creationix/nvm.git ~/.nvm
source ~/.nvm/nvm.sh
echo "source ~/.nvm/nvm.sh" >> ~/.bashrc
nvm install v0.8.5
nvm alias default v0.8.5
On OS X, you can ensure that ~/.bash_profile
loads ~/.bashrc
by making ~/.bash_profile
contain the following:
[[ -s ~/.bashrc ]] && source ~/.bashrc
To use a version of Node.js that you previously installed, pass it to nvm use
:
nvm use v0.8.4
Basic HTTP Server
var http = require('http');
var server = http.createServer(function(request, response) {
var url = request.url;
response.writeHead(200, {
'Content-Type': 'text/html'
});
response.end("<h1>Hello from Node.js!</h1><p>You request the URL: " + url + "</p>");
});
server.listen(3000);
Links
Xcode
Download and install Xcode from the Apple website. For Xcode 4.4 and above, install the Command Line Tools from the Xcode → Preferences menu, in the Downloads tab.
Installing Git
You can install Git via a package manager like Homebrew, or download an installer from the Git website.
Installing NVM
On OS X, you can ensure that
~/.bash_profile
loads~/.bashrc
by making~/.bash_profile
contain the following:To use a version of Node.js that you previously installed, pass it to
nvm use
:Basic HTTP Server