Friday, March 21, 2014

How to Disable the Undefined Response on Node.js Console

On the REPL command line, enter the following:


 module.exports.repl.ignoreUndefined = true;

Saturday, March 15, 2014

Install npm and node locally without sudo or root privilege

Updated 7/21

Trying to play with node and meteor in my own directory with invoking root privilege

By default all these packages will assume default of /usr/local. We need to change that

In .bash_profile, add:

export npm_config_prefix=$HOME/local # For npm
export PREFIX=$HOME/local
export N_PREFIX=$HOME/local # For n



Make sure the changes are in effect by running:  

. ~/.bash_profile 


For npm
  1. Download the install script from https://npmjs.org/install.sh. At the time of writing, this URL issues a 301 redirect, so we need the '-L' switch to follow the redirection. To specify the prefix, we need 'npm_config_prefix' (covered in .bash_profile)

  2. curl -L https://npmjs.org/install.sh | /bin/sh   
For node or other packages installable by npm
  1. Node is installed via npm and the prefix is specified by N_PREFIX (covered in .bash_profile)

  2. npm install -g n

  3. Install the versions
  4. n stable
Do note the above: npm install -g means the package will be installed relative to the current location

Reference: https://www.npmjs.org/doc/files/npm-folders.html