Error trying to fix NPM installtion

Originally I was trying to fix "Cannot find module 'npmlog'" issue on my centos server. looking at stackoverflow I found a recommended solution that worked for others:

curl -0 -L http://npmjs.org/install.sh | sudo sh

But I keep getting the flowing error:

curl -0 -L http://npmjs.org/install.sh | sudo sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   193    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  6711  100  6711    0     0   9554      0 --:--:-- --:--:-- --:--:--  9554
npm cannot be installed without nodejs.
Install node first, and then try again.

Maybe node is installed, but not in the PATH?
Note that running as sudo can change envs.

PATH=/sbin:/bin:/usr/sbin:/usr/bin

I have node installed and my path is ok

echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin:/etc/init.d/:/root/bin:/tradair/tools/node-v0.8.19/bin/

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

This will fix the npmlog missing module issue:

cd <node_home>/bin
mv npm npm.orig
ln -s ../lib/node_modules/npm/cli.js npm