Solve sudo: npm: command not found

Problems encountered on centos

sudo npm install *** 提示  sudo: npm: command not found

But it is possible to directly execute npm install *** by switching to the root user through su  , I don't understand.

 

You can execute the following two sentences through the guidance of an expert.

 

sudo ln -s /usr/local/bin/npm /usr/bin/npm
sudo ln -s /usr/local/bin/node /usr/bin/node

 

Done, I know this is a link but why is this happening, I still don't understand

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326788440&siteId=291194637