Monday, June 17, 2013

Installing Node.js for ACS under current user

Installing node using a package manager is simple on most platforms, but NPM still wants to run as root for most things.  BAD idea unless you want your machine to be pwned.

Here is how I did it;

1) download node.js source from the distro site.  I downloaded it to $home/local/src.  At the time of writing Node 0.8.13 is the minimum version needed for ACS support.
2) decide where you want to install it.  I chose $HOME/local
3) create/edit the file ~/.npmrc and add the following;
root =    /$HOME/local/lib/node_modules
binroot = /$HOME/local/local/bin
manroot = /$HOME/local/share/man

4) cd into your source folder and install node
./configure --prefix=~/local
make
make install

5) Create a ~/.node_modules symlink
cd
ln -s local/lib/node_modules .node_modules

6) Add the following to your ~/.bash_profile directory
export PATH=$HOME/local/bin:$PATH

7) type
which npm

If it says ~/local/bin/npm you are done

I adapted the instructions 1 to 7  from this original blog

8) install ACS
npm install -g acs

9) check your ACS install
acs login

10) you will be promoted for your username and password
ACS: Appcelerator Cloud Services Command-Line Interface, version 1.0.3
Copyright (c) 2012-2013, Appcelerator, Inc.  All Rights Reserved.

username:

11) if successful you should see
Welcome back, xxxx! You are now logged in.

12) Now you need to ensure Titanium know where your install is.  On a mac, go to Titanium Studio > Preferences > Studio > NodeJS

Set your Node Executable and Node Source paths as appropriate.  Your detected path should match the path set in step 4 above