sudo:npm:找不到命令 [英] sudo: npm: command not found
问题描述
我正在尝试升级到最新版本的节点.我正在按照 http://davidwalsh.name/upgrade-nodejs
I'm trying to upgrade to the latest version of node. I'm following the instructions at http://davidwalsh.name/upgrade-nodejs
但是当我这样做时:
sudo npm install -g n
我得到了错误:
sudo: npm: command not found
npm无需sudo即可工作.当我这样做时:
npm works without sudo. When I do:
whereis node
我知道了
node: /usr/bin/node /usr/lib/node /usr/bin/X11/node /usr/local/node
运行:
which npm
显示:
/usr/local/node/bin/npm
我在 https://stackoverflow.com/a/5062718/1246159
但是我仍然遇到相同的错误.我还查看了/etc/sudoers文件,相关的行是:
But I'm still getting the same error. I also looked at the /etc/sudoers file and the relevant line is:
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
这对我来说很好.我该如何使用sudo命令使NPM正常工作?
This looks fine to me. How can I possibly get NPM working with sudo command?
推荐答案
npm文件应位于/usr/local/bin/npm
中.如果不存在,请在其网站上再次安装该软件包的node.js.就我而言,这行得通.
The npm file should be in /usr/local/bin/npm
. If it's not there, install node.js again with the package on their website. This worked in my case.
这篇关于sudo:npm:找不到命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!