4

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
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Jhonatan
  • 1,191
  • 2
  • 10
  • 21

4 Answers4

10

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

Long Nguyen
  • 9,898
  • 5
  • 53
  • 52
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)

Ericgit
  • 6,089
  • 2
  • 42
  • 53
  • 1
    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 ¿? – Jhonatan Feb 19 '21 at 18:51
  • check your project directory permission – Ericgit Feb 20 '21 at 04:27
  • 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 error – Jhonatan Feb 22 '21 at 17:46
4

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.

3

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

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

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

Vasily
  • 59
  • 3
  • 2
    Just removing the `.npmrc` don't dismiss the error. What's the concept behind removes the `.npmrc`? – alvaropaco May 19 '21 at 14:50
  • Probably connected to the tip from The Cowacorn: removing a _folder_ named `%userprofile%/.npmrc solves the issue – dube Mar 24 '22 at 23:44