yarn "Error: EISDIR: illegal operation on a directory, read"
Asked Answered
D

4

5

Suddenly yarn is not working. Npm works perfectly but yarn only is able to run yarn -v, any other command such as yarn, yarn test, or yarn watch shows this error

Arguments: 
  /home/my.user/.nvm/versions/node/v14.15.4/bin/node /home/my.user/.nvm/versions/node/v14.15.4/bin/yarn

PATH: 
  /home/my.user/.nvm/versions/node/v14.15.4/bin:/home/my.user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Yarn version: 
  1.22.10

Node version: 
  14.15.4

Platform: 
  linux x64

Trace: 
  Error: EISDIR: illegal operation on a directory, read

npm manifest: 
  {
    "name": "one",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
      "test": "echo 'hello'"
    },
    "keywords": [],
    "author": "",
    "license": "ISC"
  }

yarn manifest: 
  No manifest

Lockfile: 
  No lockfile
Derayne answered 19/2, 2021 at 15:29 Comment(0)
P
14

In my case, after deleting yarn.lock file, I could install dependencies normally

Pretext answered 24/1, 2022 at 9:12 Comment(0)
D
7

It seems yarn is looking for a .npmrc file. It however finds a directory with the same name, then puts out the error when it tries to read it. Removing the directory will remove the error. That is the concept behind the .npmrc removal.

Denysedenzil answered 30/8, 2021 at 8:45 Comment(3)
Nice find! This might be because the installation guide for nvm-windows claims that one should migrate the npmrc file to %userprofile%/.npmrc/.npmrcMegganmeggi
on ubuntu, I had to remove /usr/local/etc/npmrc and ~/.npmrcDrivein
On an older synology dsm, I also had to delete ~/.npmrcHaskins
A
4

EISDIR stands for "Error, Is Directory". This means that yarn is trying to do something to a file but it is a directory. In your case, yarn 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 of here.

Make sure the file exists. If it does not, you need to create it. (If yarn 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)

Aigrette answered 19/2, 2021 at 15:32 Comment(3)
Which file are we talking about here? I'm just trying to run an npm script with yarn. e.g yarn watch. Which file should I take a look at? Package.json? One yarn binary ¿?Derayne
check your project directory permissionAigrette
this seems to not working. I've check permissions and it seems it has to do with yarn itself. I can't even run yarn --help cause I get the same errorDerayne
A
4

Try to find and remove .npmrc, which is located in

Windows: C:/users/<your username>/.npmrc

Ubuntu: /home/<your username>/.npmrc

Astrosphere answered 22/3, 2021 at 12:4 Comment(2)
Just removing the .npmrc don't dismiss the error. What's the concept behind removes the .npmrc?Korey
Probably connected to the tip from The Cowacorn: removing a folder named `%userprofile%/.npmrc solves the issueMegganmeggi

© 2022 - 2024 — McMap. All rights reserved.