I have 2 nodejs
installation v0.8.18
( executable name is node
) and v0.10.20
(executable name is nodejs
) in my ubuntu 12.04 system.
when I running npm install
how can I specify npm use the executable named "nodejs" instead of "node"
If you in-fact actually want to toggle between various nodejs releases, there is an environment variable NODE_PATH which controls the directory path node uses to reach modules. The other issue is the env var PATH which the unix uses to reach executables, IE. node and npm
Additionally, node/npm uses these dirs/files :
~/.npmrc
~/.npm
~/tmp
~/.npm-init.js
those may or may not be impacted by different releases of node. If you install each release from source code you have full control of NODE_PATH and PATH
source code for all releases available at http://nodejs.org/dist/
Below are the steps to install a given release from source NOTE - this installs nodejs which gives you both node as well as npm, they come together per release.
to start fresh remove prior node.js and npm installs as well as these :
sudo mv ~/.npmrc ~/.npmrc_ignore
sudo mv ~/.npm ~/.npm_ignore
sudo mv ~/tmp ~/tmp_ignore
sudo mv ~/.npm-init.js ~/.npm-init.js_ignore
to install nodejs and npm as yourself NOT root do these commands (OSX/linux) :
parent_dir=${HOME}/bin_xxxx # replace bin_xxx with something specific
# to node release like bin_v0.10.31
mkdir ${parent_dir}
download source from : http://nodejs.org/download/
cd node-v0.xxxx
./configure --prefix=${parent_dir}/nodejs
make -j8
make install
which puts it into dir defined by above --prefix
export PATH=${parent_dir}/nodejs/bin:$PATH
define environment variable NODE_PATH so node can find dir for modules otherwise npm install xxx will put newly installed module into dir in curr dir :
export NODE_PATH=${parent_dir}/nodejs/lib/node_modules
do above AND use syntax : npm install -g some_cool_module always use the -g for global so it gets installed into dir $NODE_PATH and not your $PWD
nodejs install gives you npm as well :
ls -la ${parent_dir}/nodejs/bin