Ishwarya Ishwarya - 3 months ago 52
Node.js Question

upgrade nodejs to stable version

I am trying to update nodejs version using npm.

Install nodejs:

sudo yum install nodejs npm --enablerepo=epel


Check Version

[root@*********** ec2-user]# node -v
v0.10.46
[root@*********** ec2-user]# npm -v
1.3.6


Install n and Update nodejs:

[root@ip************#] sudo npm install -g n

npm http GET https://registry.npmjs.org/n
npm http 200 https://registry.npmjs.org/n
npm http GET https://registry.npmjs.org/n/-/n-2.1.4.tgz
npm http 200 https://registry.npmjs.org/n/-/n-2.1.4.tgz
/usr/bin/n -> /usr/lib/node_modules/n/bin/n
npm WARN unmet dependency /usr/lib/node_modules/block-stream requires inherits@'~2.0.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/fstream requires inherits@'~2.0.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/fstream-ignore requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/fstream-npm requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/glob requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/npmconf requires inherits@'~2.0.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/tar requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
n@2.1.4 /usr/lib/node_modules/n



[root@i*************# n stable

install : node-v6.4.0
mkdir : /usr/local/n/versions/node/6.4.0
fetch : https://nodejs.org/dist/v6.4.0/node-v6.4.0-linux-x64.tar.gz
######################################################################## 100.0%
installed : v0.10.46


Check the Version:

[root@*********** ec2-user]# node -v
v0.10.46
[root@*********** ec2-user]# npm -v
1.3.6

[root@*********** ec2-user]#/usr/local/bin/node -v
v6.4.0
[root@*********** ec2-user]# /usr/local/bin/npm -v
3.10.3


When i do which node and which npm from root user:

[root@ip-********]# which node
/usr/bin/node
[root@************]# which npm
/usr/bin/npm


if i login as ec2-user instead of root its showing recent version correctly :

[ec2-user@ip************** ~]$ node -v
v6.4.0
[ec2-user@ip************** ~]$ npm -v
3.10.3
[ec2-user@ip************** ~]$ which node
/usr/local/bin/node
[ec2-user@ip************** ~]$ which npm
/usr/local/bin/npm


Can anyone please help me out here to resolve this issue.

Tom Tom
Answer

It's kinda hack but you can resolve it by creating symlink

mv /usr/bin/node /usr/bin/bnode ln -s /usr/local/bin/node /usr/bin/node mv /usr/bin/npm /usr/bin/bnpm ln -s /usr/local/bin/npm /usr/bin/npm

Comments