升级nodejs到稳定版
upgrade nodejs to stable version
我正在尝试使用 npm 更新 nodejs 版本。
安装nodejs:
sudo yum install nodejs npm --enablerepo=epel
检查版本
[root@*********** ec2-user]# node -v
v0.10.46
[root@*********** ec2-user]# npm -v
1.3.6
安装 n 并更新 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
检查版本:
[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
当我从 root 用户执行哪个节点和哪个 npm 时:
[root@ip-********]# which node
/usr/bin/node
[root@************]# which npm
/usr/bin/npm
如果我以 ec2-user 而不是 root 身份登录,它会正确显示最新版本:
[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
谁能帮我解决这个问题。
有点乱,但您可以通过创建符号链接来解决它
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
我正在尝试使用 npm 更新 nodejs 版本。
安装nodejs:
sudo yum install nodejs npm --enablerepo=epel
检查版本
[root@*********** ec2-user]# node -v
v0.10.46
[root@*********** ec2-user]# npm -v
1.3.6
安装 n 并更新 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
检查版本:
[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
当我从 root 用户执行哪个节点和哪个 npm 时:
[root@ip-********]# which node
/usr/bin/node
[root@************]# which npm
/usr/bin/npm
如果我以 ec2-user 而不是 root 身份登录,它会正确显示最新版本:
[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
谁能帮我解决这个问题。
有点乱,但您可以通过创建符号链接来解决它
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