无论我在什么目录下,无论我在cmd.exe中键入“npm”后,我都被这个错误卡住了。下面是npm-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js' ]
2 info using npm@2.14.12
3 info using node@v4.2.6
4 verbose stack Error: EISDIR: illegal operation on a directory, read
4 verbose stack     at Error (native)
5 verbose cwd C:\Users\me
6 error Windows_NT 6.1.7601
7 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js"
8 error node v4.2.6
9 error npm  v2.14.12
10 error code EISDIR
11 error errno -4068
12 error syscall read
13 error eisdir EISDIR: illegal operation on a directory, read
13 error eisdir This is most likely not a problem with npm itself
13 error eisdir and is related to npm not being able to find a package.json in
13 error eisdir a package you are trying to install.
14 verbose exit [ -4068, true ]

I have tried and uninstalling/reinstalling nodejs multiple times, I even deleted npm and npm-cache folders in C:\Users\me\AppData\Roaming. I'm not sure what went wrong to cause this. One second it was working fine, and now I can't get rid of this error. The explanation in the log does not make sense, as it gives this error in any directory. I should note that running a command prompt as administrator does not give this error. I'm pulling my hair out this Friday evening trying to get this fixed, any help would be greatly appreciated!


当前回答

在我的mac升级之后。我开始有这个问题。我尝试重新安装nvm, node, npm,清除npm缓存,删除node_modules文件夹后重新安装项目的依赖项,重置npmrc…

唯一有效的方法是再次克隆项目,并且从相同的分支和相同的提交中工作。

其他回答

做一个完整的卸载,包括删除路径等,重新安装已经解决了这个问题,虽然非常奇怪的问题。

如何从Windows中完全删除node.js

EISDIR代表“错误,是目录”。这意味着NPM试图对一个文件做一些事情,但它是一个目录。在你的例子中,NPM试图“读取”一个目录文件(行:4)。由于操作不能完成,错误被抛出。

这里有三件事要确定。

确保文件存在。如果没有,则需要创建它。(如果NPM依赖于文件中的任何特定信息,你将需要在那里有这些信息)。 确保它实际上是一个文件,而不是一个目录。 它具有正确的权限。可以使用“sudo chmod 777 FILE_NAME”将文件修改为拥有所有权限。(注意:你给了读,写和执行权限的文件上的每个人)

如果您的问题与React Native打包器相关。尝试使用react-native start——reset-cache重置缓存。

在我的情况下,我得到了“EISDIR:非法操作的目录,读取”,因为在我的.angular-cli。我没有在“脚本”中提供完整的路径:

例如,我有

"scripts": [
        "../node_modules/hammerjs",
        "../node_modules/moment"
      ],

事实上,它本该如此

"scripts": [
        "../node_modules/hammerjs/hammer.min.js",
        "../node_modules/moment/min/moment.min.js"
      ],

对于mac os: 如果直接从nodejs网站安装,npmrc文件将位于/usr/local/etc/npmrc只要删除未定义的配置,这个问题就会得到解决。