以centos 6.5 x64 环境为例,之前安装方式是编译过后建立软链接方式。
1、查看node环境
[root@localhost /]# node -v
v4.2.1
[root@localhost /]# npm -v
2.14.7
[root@localhost /]#
node运行的核心就是node、npm和node modules。
2、找出node所有相关文件
[root@localhost /]# whereis node
node: /usr/bin/node /usr/local/bin/node
[root@localhost /]# whereis npm
npm: /usr/bin/npm /usr/local/bin/npm
[root@localhost /]# whereis node_modules
node_modules: /usr/local/lib/node_modules
[root@localhost /]#
[root@localhost /]# rm -rf /usr/bin/node
[root@localhost /]# rm -rf /usr/local/bin/node
[root@localhost /]# rm -rf /usr/bin/npm
[root@localhost /]# rm -rf /usr/local/bin/npm
[root@localhost /]# rm -rf /usr/local/lib/node_modules
usr/local/bin部分是软链接。
[root@localhost /]# find / -name node
/file/software/node-v4.2.1-linux-x64/include/node
/file/software/node-v4.2.1-linux-x64/bin/node
/file/software/node-v4.2.1-linux-x64/lib/node_modules/sails/node_modules/grunt-sync/node_modules/promised-io/engines/node
/file/software/node-v4.2.1-linux-x64/share/doc/node
/usr/local/include/node
/usr/local/n/versions/node
/usr/local/n/versions/node/4.2.1/include/node
/usr/local/n/versions/node/4.2.1/bin/node
/usr/local/n/versions/node/4.2.1/share/doc/node
/usr/local/share/doc/node
由于安装了node自身升级,所有n/versions目录存在。
删除相关文件夹即可。
[root@localhost /]# rm -rf /file/software/node-v4.2.1-linux-x64
[root@localhost /]# rm -rf /usr/local/include/node
[root@localhost /]# rm -rf /usr/local/n
[root@localhost /]# rm -rf /usr/local/share/doc/node
-rf是递归强制删除,需要删除的只需要上级节点即可。
[root@localhost /]#
3、其他相关文件删除
express、pm2 、sails
[root@localhost /]# whereis pm2
pm2: /usr/local/bin/pm2
[root@localhost /]# whereis express
express: /usr/local/bin/express
[root@localhost /]# whereis sails
sails: /usr/local/bin/sails
[root@localhost /]# rm -rf /usr/local/bin/pm2
[root@localhost /]# rm -rf /usr/local/bin/express
[root@localhost /]# rm -rf /usr/local/bin/sails
4、重启服务器
看看服务目前状态:
[root@localhost /]# node -v
-bash: /file/software/node-v4.2.1-linux-x64/bin/node: No such file or directory
[root@localhost /]# npm -v
-bash: /file/software/node-v4.2.1-linux-x64/bin/npm: No such file or directory
重启后就变成:
[root@localhost ~]# node -v
-bash: node: command not found
完成。