2

I install node.js on centos6.5 and node.js has no problem ,but when i test npm -v

[root@localhost ~]# npm -v

module.js:340
    throw err;
          ^
Error: Cannot find module 'npmlog'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at /usr/bin/npm:18:11
    at Object.<anonymous> (/usr/bin/npm:86:3)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
zimmer
  • 1,159
  • 3
  • 13
  • 23
  • Please check [this question](http://stackoverflow.com/questions/20028996/how-to-install-node-binary-distribution-files-on-linux) – mehmetseckin Nov 22 '14 at 14:48

1 Answers1

0

Following instructions work

Below are the steps to install Node.js from source (OSX/linux) You may/should issue all these cmds as yourself NOT root (sudo)

NOTE - this installs Node.js which gives you both node as well as npm, they come together per release.

to start fresh remove prior node 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

download source from : http://nodejs.org/download/

cd node-v0.10.33

define environment variable NODE_PATH as the dir for subsequent module installs

export NODE_PARENT=/some/desired/install/path_goes_here

export NODE_PARENT=/usr/local/bin/nodejs    # use this if you want to install as root (sudo)
export NODE_PARENT=${HOME}/nodejs-v0.10.33  # use this if you want to install modules as yourself

export PATH=${NODE_PARENT}/bin:${PATH}
export NODE_PATH=${NODE_PARENT}/lib/node_modules

./configure   --prefix=${NODE_PARENT}

make
make install   

which puts it into dir defined by above --prefix

when you use syntax : npm install -g some_cool_module the -g for global installs it into dir $NODE_PATH and not your $PWD

Now put above three export xxx=yyy commands into your ~/.bashrc or some such to persist these environment variable changes

Scott Stensland
  • 26,870
  • 12
  • 93
  • 104