本文介绍了须藤:npm:找不到命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试升级到最新版本的节点.我正在按照 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"

这对我来说很好.我怎样才能让 NPM 使用 sudo 命令?

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.

这篇关于须藤:npm:找不到命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 17:11