I was looking for a way to install NodeJs, NPM, Yeoman, without messing with the system files in my OSX but I didn’t find any, so here is my setup kind of guide
- Download node.js binaries (tar.gz) from nodejs.org
- Open a Terminal session and execute the following commands:
cd mkdir Development cd Development tar xvf ../Downloads/node-v0.10.28-darwin-x64.tar.gz cd node-v0.10.28-darwin-x64/bin sudo pwd > /etc/paths.d/nodejs
What just happened?
- cd will change your location to the home folder
- mkdir Development will create a folder to store the dev utilities, you can change to any other you like
- cd Development moves to Development folder
- tar xvf <path to your download nodejs file> extracts contents of tar.gz file into Development folder
- cd node-v0.10.28-darwin-x64/bin moves to the bin folder
- sudo pwd > /etc/paths.d/nodejs creates a file named “nodejs” with a line, the full path to node bin folder in folder /etc/paths.d
- exit ends terminal session
The file generated by the last line, will be used to calculate the environment variable PATH in OSX, and because of this makes node and npm available to the Apps installed in your system and also to the new terminal sessions
That’s it! now you have installed Node.js and Node Package Manager (npm)
Now, let’s suppose you want to install the http-server package, just open a Terminal session and launch the following command:
npm install -g http-server
npm does its magic and will install “globally” the “http-server” package, which you can use right away!
You may be wondering… where it was installed? the executable was installed to the bin folder in your local installation of Node.js and the actual files in the lib/node_modules folder inside the node folder.