简体   繁体   中英

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

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

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)

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.

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

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM