无论我在什么目录下,无论我在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!


当前回答

同样的问题,直到我尝试删除。git文件夹。它工作。我想这类问题可能有不同的原因。

其他回答

一定要检查你的npm版本,看看它是否有问题。在写这篇文章的时候,我也遇到了同样的问题,我发现我的npm版本(6.5)也有问题。我不得不卸载并重新安装npm 6.4.1版本,然后一切又开始正常工作了。

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

例如,我有

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

事实上,它本该如此

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

所以大多数答案都说它与.npmrc文件有关。

在我的例子中,我正在使用无服务器部署和消息部署无服务器应用程序

EISDIR:在目录上进行非法操作,请断开“/home/malvadao/workspace/project/.build/node_modules”的链接

被扔了出去。

删除.build文件夹对我来说就是这样。它是Typescript编译后生成的文件夹。由于文件夹是在启动无服务器部署命令后重新创建的,因此它足以解决问题并继续流程。

换句话说,手动删除文件夹可能足以让您继续前进,而不需要触摸.npmrc

确保node_modules(和你的根package.json)不包含对npm的“package”的引用。json”模块。删除包。node_modules的json文件夹为我解决了这个问题。

我只是去掉了这条线

.babel('resources/assets/js/app.js')

对于laravel 5.6和vue.js。在webpack.mix.js