为什么npm一切都需要sudo? [英] Why does npm need sudo for EVERYTHING?

查看:198
本文介绍了为什么npm一切都需要sudo?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何管理它,但是npm似乎绝对需要每个命令使用 sudo ,即使 npm help 在没有sudo的情况下也不起作用.如果我使用的命令没有 sudo ,则不会看到 EACCESS 错误,而是我的终端会话挂起,然后关闭该选项卡(我在Mac上使用iTerm).

I don't know how I've managed it but npm seems to need sudo for absolutely every command, even npm help does not work without sudo. If I use a command without sudo, I do not see am EACCESS error, but instead my terminal session hangs and then just closes that tab (I use iTerm on Mac).

我尝试更改我的本地 .npm 文件夹的所有权,在此处在安装了node的/usr/local/bin 文件夹中也做了同样的操作,但是即使安装了本地软件包,这些都不允许我在没有 sudo 的情况下直接运行npm...!在我看来,有些事情发生了,有人可以帮忙吗?

I have tried changing the ownership of my local .npm folder, outlined here and also done the same on my /usr/local/bin folder where node is installed but none of these allow me to just run npm without sudo, even when installing local packages...! It seems to me that something has screwed along the way, can anyone help?

非常感谢

推荐答案

今天重新安装0.12.4后,我遇到了相同的错误;这为我解决了问题:

I encountered the same error after a fresh install of 0.12.4 today; this solved the problem for me:

sudo chown -R $(whoami):admin /usr/local/lib/node_modules

在我的特定情况下,我注意到该文件夹​​归'{some-large-integer-account}:wheel'... YMMV拥有

In my particular case, I noticed that this folder was owned by '{some-large-integer-account}:wheel'...YMMV

如果仍然不能解决问题,请查看EACCESS错误跟踪中提到的被阻止文件夹的所有权.如果您不确定所有权 应该是什么,通常可以从同级兄弟的所有权中推断出这一点.

If that doesn't solve it, take a look at the ownership of the folders that are being blocked as mentioned in the EACCESS error trace. If you're not sure what the ownership should be, you can usually infer it from the sibling dirs' ownership.

这篇关于为什么npm一切都需要sudo?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆