Wednesday, May 7, 2014

Install Node.js from git

node.js did not work properly for me through apt-get so I installed it from source.

git clone https://github.com/joyent/node.git

./configure
make
make install

npm is already included with node so there is not need to install.

To solve the error:
Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
use the following commands:
npm config set nodedir /directory/to/node
npm config set nodedir /directory/to/node --global

This is because "npm install" needs node's source for binary compilation.  Make sure that directory is permanent.  I have mine so that I can git pull a newer version right in that directory or change versions without any other major modifications.  The first line represents the current user's npm config file and the second represents the global config file.

No comments:

Post a Comment