nodejs覆盖/ usr / bin /其中,如何解决?

我有一个新安装的centos 7只有一些nodejs项目。 然后我发现which命令不能正常工作。

 # which ls which: illegal option -- - usage: which [-as] program ... # echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin 

但是这个工作:

 # /usr/bin/which ls /usr/bin/ls 

然后我做了一个cat /usr/bin/which ,发现它已经被一个nodejs程序取代了!

 #!/usr/bin/env node var which = require("../") if (process.argv.length < 3) usage() function usage () { console.error('usage: which [-as] program ...') process.exit(1) } ... ... 

which命令是一个节点程序

 # ls -la /usr/bin/which lrwxrwxrwx 1 root root 63 Jul 5 20:43 /usr/bin/which -> ../local/share/.config/yarn/global/node_modules/which/bin/which 

我很困惑,为什么地狱会replace一个完美的系统命令?

现在的问题是,解决这个问题的正确方法是什么? 我可以只删除该文件, which从另一台计算机(vm)复制?

更新:

这里是我如何安装nodejs和纱线。 其他模块安装在项目目录中。

 curl --silent --location https://rpm.nodesource.com/setup_6.x | bash - yum install nodejs sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo yum install yarn yarn global add nuxt yarn global add cross-env npm install pm2 -g 

在Fedora中安装纱线时遇到同样的问题。

我意识到,不使用绝对path调用的命令实际上是一个别名。

 # alias which alias which='(alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot' 

在Fedora中使用下面的rpm命令,我也可以确认/ usr / bin /哪个软链接被replace了。

 # rpm -V which ....L.... /usr/bin/which 

我解决了重新安装哪个软件包的问题。

 sudo yum reinstall which 

我不认为这是正确的nodejs应该取代一个重要的系统程序,所以客人这是一个问题在nodejs开发团队。

PS:对不起,我的英文。