Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM stuck giving the same error EISDIR: Illegal operation on a directory, read at error (native)

People also ask

How do you fix Eisdir illegal operation on a directory read?

EISDIR mean its a directory and not a file. To fix the issue, I deleted the file and just recreated (it was originally created automatically). If you cannot find the file (because its hidden), simply use the terminal to find and delete it.

What is Eisdir?

EISDIR means that the target of the operation is a directory in reality but that the expected filetype of the target is something other than a directory.


EISDIR stands for "Error, Is Directory". This means that NPM is trying to do something to a file but it is a directory. In your case, NPM is trying to "read" a file which is a directory (Line: 4). Since the operation cannot be done the error is thrown.

Three things to make sure here.

  1. Make sure the file exists. If it does not, you need to create it. (If NPM depends on any specific information in the file, you will need to have that information there).
  2. Make sure it is in fact a file and not a directory.
  3. It has the right permissions. You can change the file to have all permissions with "sudo chmod 777 FILE_NAME". (Careful: You are giving Read, Write and Execute permissions to every one on that file)

I ran into the same problem while I was changing some npm settings. I did a mistake with one npm config set command and this added a line referring to a non-existing directory to C:\Users\{User}\.npmrc. After I deleted that line manually from .npmrc, the problem was gone.


Had the same problem today after i've upgraded my npm from version 6.4.1 to version 6.5.0. I fixed this by downloading the .pkg installer (recommended for most users) from node.js and runned it afterwards.


In my case I was getting the "EISDIR: illegal operation on a directory, read" because in my .angular-cli.json file I wasn't providing a full path in "scripts:"

For example I had

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

In fact it should have been

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

I had the same issue on Mac OS X (installed with homebrew), and the .npmrc is not the only place node stored config variables. There is a glocal npmrc config file in /usr/local/etc that you have to edit using this command:

sudo nano npmrc

Remove the ca= line, or whatever the config setting was that broke your install, save that file, and try npm again, and you should see it working.