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

I am stuck with this error no matter what directory I am in, and what I type after “npm” in cmd.exe. Here is the 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 [email protected]
3 info using [email protected]
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!

37 Answers
37

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)

Leave a Comment