通过 npm returns 安装共付额:不能 运行 在 wd %s %s (wd=%s)

Install copay via npm returns: cannot run in wd %s %s (wd=%s)

我正在执行 npm install 作为 sudo 来安装 copay bitcopay 但由于某种原因,我收到此错误。

$ sudo npm install
Password:
npm WARN lifecycle copay@2.7.0~preinstall: cannot run in wd %s %s (wd=%s) copay@2.7.0 bower install /Users/Jarvis/Documents/Projects/copay
npm WARN lifecycle copay@2.7.0~postinstall: cannot run in wd %s %s (wd=%s) copay@2.7.0 npm run build /Users/Jarvis/Documents/Projects/copay
copay@2.7.0 /Users/Jarvis/Documents/Projects/copay

没有找到好的解决方法。有人有解决办法吗?

正如我最近发现的那样,this explanation 正中要害。

正如马努所说:

On digging a bit deep, I found that NPM tries to downgrade its privileges when it runs scripts. That downgrading the privileges causes this error.

我 运行 试图以 root 身份在 docker 容器中 运行 遇到类似的问题。 "npm install --unsafe-perm" 解决方案对我有用。

来自黑客新闻的 jfroma 说 "don't do this"。虽然他们解释了这种情况,但他们没有解释为什么它不安全并向您推荐 npm config page ,但是,该页面仅解释了它是一个 true/false 配置,关于权限是否 de-escalated 在安装过程中。

实际上,如果您查看 the broader conversation that jfroma's comment is in,您可以推断出危险在于 npm 包中很容易包含 "rm -fr /"。如果你 运行 npm 以 root 身份使用 --unsafe-perm 安装那个包,你会很伤心。

因为我 运行 将此安装安装在 docker 容器中,我每次都从源代码 re-creating 构建,它可能足够安全。我可以随时返回仓库取回我的东西。

如果您尝试在您的工作站上安装一些东西,也许 adjusting the permissions of your installation 会更好?