I have a newly installed centos 7 with only some nodejs projects. Then I found which
command is not working properly.
# which ls
which: illegal option -- -
usage: which [-as] program ...
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
but this works:
# /usr/bin/which ls
/usr/bin/ls
Then I did a cat /usr/bin/which
, found it has been replaced by a nodejs program!
#!/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
command is a node program
# 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
I am confused as hell, why the hell would nodejs replace a perfectly working system command?
Now the question is, what is the correct way to fix it? Can I just delete the file and copy which
from another computer(vm)?
update:
Here is how I installed nodejs and yarn. Other modules was installed in project dir.
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