NPM stuck giving the same error EISDIR: Illegal operation on a directory, read at error (native)
Solution 1:
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.
- 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).
- Make sure it is in fact a file and not a directory.
- 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)
Solution 2:
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.
Solution 3:
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.
Solution 4:
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"
],
Solution 5:
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.