npm:未处理的拒绝错误:EISDIR:对目录进行非法操作,打开‘/Users/me/.npm/_cacache/content-v2/sha512/b3/da’ [英] npm: Unhandled rejection Error: EISDIR: illegal operation on a directory, open ‘/Users/me/.npm/_cacache/content-v2/sha512/b3/da’

查看:510
本文介绍了npm:未处理的拒绝错误:EISDIR:对目录进行非法操作,打开‘/Users/me/.npm/_cacache/content-v2/sha512/b3/da’的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Mac 上,我刚刚将我的工作 npm 版本从 5.6 更新到 6.9:

On my Mac, I just updated my working npm version from 5.6 to 6.9 thusly:

sudo npm i -g npm

然后我尝试像这样安装cordova:

Then I tried to install cordova like this:

sudo npm install -g cordova

并得到

Unhandled rejection Error: EISDIR: illegal operation on a directory, 
open '/Users/me/.npm/_cacache/content-v2/sha512/04/89'
npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <https://npm.community>

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/me/.npm/_logs/2019-04-02T11_50_57_678Z-debug.log

我试图这样降级:

sudo npm install -g npm@6.4.1

但是这失败了数百行,如下所示:

but this fails with hundreds of lines like this:

npm WARN tar EISDIR: illegal operation on a directory, open '/tmp/npm-30934-a3ac319a/unpack-28da209e/bin/node-gyp-bin'
Unhandled rejection Error: EISDIR: illegal operation on a directory, open '/Users/me/.npm/_cacache/content-v2/sha512/99/72'

我还尝试确保所有权正确:

I also tried making sure the ownership was correct:

sudo chown -R $(whoami) ~/.npm

有很多关于其他目录(例如/usr/lib/modules)的各种EISDIR(错误是目录)问题的帖子,但似乎没有解决方案.

There are lots of posts of various EISDIR (error is a directory) problems for other directories (such as /usr/lib/modules), but no solutions seem to work.

另外,npmrc 文件似乎也不存在.如果我这样做:

Also, the npmrc file does not seem to exist. If I do:

npm config ls -l

globalconfig = "/usr/local/etc/npmrc"
userconfig = "/Users/me/.npmrc"

但两个文件都不存在.

注意,我没有自制软件,也没有那样安装(我通常手动安装).

Note, I dont have homebrew, and didnt install it that way (I usually do manual installs).

我也试过这个:

sudo npm cache clean -f

这没有帮助.

我还能尝试什么?我应该尝试删除 ~/.npm 目录吗?

What else can I try? should I try deleting the ~/.npm dir?

在寻找卸载 node 的方法时,我发现了许多旧帖子,其中包含要删除的长且有时相互冲突的文件列表.不确定这是否会使情况变得更糟.

Looking for a way to uninstall node, I found many old posts with long and sometimes conflicting lists of files to remove. Not sure if this will make it worse.

有什么建议吗?

推荐答案

我升级到 npm 6.9.0 时遇到了同样的问题.您必须将节点升级到最新版本:

I had the same problem when I upgraded to npm 6.9.0. You have to upgrade node to the last version:

brew 重新安装节点

brew reinstall node

此时我已经安装了 Mac OS Mojave 的最新可用版本(节点:v11.14.0 和 npm 6.9.0).

At this time I have installed the latest available version for Mac OS Mojave (node: v11.14.0 and npm 6.9.0).

节点升级后,我能够再次全局安装包.

After node upgrade, I was able to install packages globally again.

这篇关于npm:未处理的拒绝错误:EISDIR:对目录进行非法操作,打开‘/Users/me/.npm/_cacache/content-v2/sha512/b3/da’的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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