Yarn: error EISDIR: illegal operation on a directory, read at Error (native)

Created on 11 Oct 2016  路  28Comments  路  Source: yarnpkg/yarn

Specifically happens when trying to add this package adyen-encryption.

yarn add adyen-encryption

thomasreggi@zx:yarn-example$ yarn add sjcl
yarn add v0.15.1
[1/4] 馃攳  Resolving packages...
[2/4] 馃殮  Fetching packages...
error EISDIR: illegal operation on a directory, read
    at Error (native)
info Visit http://yarnpkg.com/en/docs/cli/add for documentation about this command.

Seems that the github repo for this module is down but it's package.json contents for generated within node_modules/adyen-encryption via npm install adyen-encryption is here:

{
  "_args": [
    [
      {
        "raw": "adyen-encryption",
        "scope": null,
        "escapedName": "adyen-encryption",
        "name": "adyen-encryption",
        "rawSpec": "",
        "spec": "latest",
        "type": "tag"
      },
      "/Users/thomasreggi/Desktop/yarn-example"
    ]
  ],
  "_from": "adyen-encryption@latest",
  "_id": "[email protected]",
  "_inCache": true,
  "_location": "/adyen-encryption",
  "_nodeVersion": "4.2.1",
  "_npmOperationalInternal": {
    "host": "packages-12-west.internal.npmjs.com",
    "tmp": "tmp/adyen-encryption-0.1.1.tgz_1461252287762_0.7548116364050657"
  },
  "_npmUser": {
    "name": "jarpi",
    "email": "[email protected]"
  },
  "_npmVersion": "2.14.7",
  "_phantomChildren": {},
  "_requested": {
    "raw": "adyen-encryption",
    "scope": null,
    "escapedName": "adyen-encryption",
    "name": "adyen-encryption",
    "rawSpec": "",
    "spec": "latest",
    "type": "tag"
  },
  "_requiredBy": [
    "#USER"
  ],
  "_resolved": "https://registry.npmjs.org/adyen-encryption/-/adyen-encryption-0.1.1.tgz",
  "_shasum": "c72f570bdbea756e44213b61bb68ca3f0750e8c9",
  "_shrinkwrap": null,
  "_spec": "adyen-encryption",
  "_where": "/Users/thomasreggi/Desktop/yarn-example",
  "author": "",
  "bugs": {
    "url": "https://github.com/corbel-platform/adyen-encryption/issues"
  },
  "dependencies": {
    "sjcl": "^1.0.3"
  },
  "description": "Adyen encryption for node or browsers. Without forms.",
  "devDependencies": {
    "chai": "^3.5.0",
    "chai-as-promised": "^5.3.0",
    "mocha": "^2.4.5"
  },
  "directories": {},
  "dist": {
    "shasum": "c72f570bdbea756e44213b61bb68ca3f0750e8c9",
    "tarball": "https://registry.npmjs.org/adyen-encryption/-/adyen-encryption-0.1.1.tgz"
  },
  "gitHead": "1b42173542a37955c1b387f1000a06e4ee83e714",
  "homepage": "https://github.com/corbel-platform/adyen-encryption#readme",
  "keywords": [
    "adyen",
    "node",
    "browser",
    "encryption"
  ],
  "license": "Unlicense",
  "main": "src/main.js",
  "maintainers": [
    {
      "name": "jarpi",
      "email": "[email protected]"
    }
  ],
  "name": "adyen-encryption",
  "optionalDependencies": {},
  "readme": "ERROR: No README data found!",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/corbel-platform/adyen-encryption.git"
  },
  "scripts": {
    "test": "npm run unit-test",
    "unit-test": "mocha -R spec ./test/**/*.spec.js"
  },
  "version": "0.1.1"
}
cat-bug

Most helpful comment

try locating and removing the .npmrc folder that is located in c:/users/your username/.npmrc

All 28 comments

Same error occurs if you yarn add sjcl from https://github.com/bitwiseshiftleft/sjcl.

Not sure if it's the same error or not, but I got "EISDIR: illegal operation on a directory" error message when my project contains 'readme' directory.

Steps to reproduce:

  1. Create new clean directory, say, my_project;
  2. Under this directory create a new empty readme directory;
  3. Add any package.json file into my_project directory, for example:
{
  "dependencies": {
    "react": "15.3.1"
  }
}

Try to launch yarn. You should see "EISDIR: illegal operation on a directory" error. Now, try to remove readme directory and launch yarn again - error is gone, installation successful.

This package seems to be the root of yarn not working on my project: object-merge

$ yarn add object-merge
yarn add v0.15.1
[1/4] 馃攳  Resolving packages...
[2/4] 馃殮  Fetching packages...
error EISDIR: illegal operation on a directory, read
    at Error (native)
info Visit http://yarnpkg.com/en/docs/cli/add for documentation about this command.

Similarly if you yarn install with this package listed in the dependencies.
Perhaps the "License" directory in the project?

I think it is occurring for me on git:// urls -- e.g. I use a fork of jquery-typewatch

"dependencies": {
    "jquery-typewatch": "git://github.com/elitedaily/TypeWatch.git#4403d23cf702248e1bad01cc0a2d462a5d828e4f",

I'm getting this for a change:

位 yarn global add http-server
yarn global v0.15.1
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed [email protected] with binaries:
      - http-server
      - hs
error EPERM: operation not permitted, open 'C:\Program Files\nodejs\hs.cmd'
    at Error (native)
info Visit http://yarnpkg.com/en/docs/cli/global for documentation about this command.

same error with blocktrail-sdk, but i'm getting a warning before...

related with https://github.com/yarnpkg/yarn/issues/653?

yarn install v0.15.1
[1/4] 馃攳  Resolving packages..
warning blocktrail-sdk > html-pdf > phantomjs > request > [email protected]: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
[2/4] 馃殮  Fetching packages..
error EISDIR: illegal operation on a directory, read
    at Error (native)
info Visit http://yarnpkg.com/en/docs/cli/install for documentation about this comman

Same results as @pjm17971 in my project. I've got a long list of dependencies, but simply removing object-merge from that list prevents the EISDIR: illegal operation on a directory, read at Error (native) error

So I've confirmed, Yarn is definitely choking on the License directory. Something that should probably be adjusted in yarn, but in the meantime, opened some PR's for @matthewkastor to consider

https://github.com/matthewkastor/object-merge/pull/11
https://github.com/matthewkastor/object-foreach/pull/1 (dependency of object-merge)
https://github.com/matthewkastor/clone-function/pull/2 (dependency of object-merge)

Note that the 2 dependencies of object-merge have the same structure. Tested with all three repos updated:

image

Obviously looks like others are getting EISDIR errors for different reasons, but this was one of them. FYI @pjm17971

I think many here would try yarn over existing projects, which in times could get into hundreds if not thousands of dependencies in the tree. However there is no proper stacktrace or package name to look at.

After upgrading to 0.16.1, I still got this error.

For proper reporting here are the meaningful things from yarn-error.log:

Trace: 
  Error: EISDIR: illegal operation on a directory, read
      at Error (native)

Had the same issue in one of my projects. The cause seems to be that I have a README.md file and a directory called README in my root directory. Adding "readme": "README.md" to my package.json fixed it.

@sfishel18 seems that there are many problems regarding the validation API, since last time I saw this was a result of "license": "".

It seems like this code is likely the problem: normalize-manifest/fix.js
it reads in a list of files:

const files = await fs.readdir(moduleLoc);

Which I think includes directories.

Then a little later, assumes it can fs.readFile() something in files:

  // get license file
  const licenseFile = files.find((filename): boolean => {
    const lower = filename.toLowerCase();
    return lower === 'license' || lower.startsWith('license.') ||
           lower === 'unlicense' || lower.startsWith('unlicense.');
  });
  if (licenseFile) {
    const licenseContent = await fs.readFile(path.join(moduleLoc, licenseFile));

Which I'm guessing blows up with the error we're seeing when that turns out to be a license directory.

Hope this helps.

Can confirm that our project has the problem because of a folder called "License" - renaming the folder is a working workaround for us.
Thanks for the hints, @pjm17971, @codfish

please fix bug with README Folder

I'm also getting this error, because of the "object-merge" package as noted above; guess I'll have to wait until that package gets fixed, but can yarn be fixed to be compatible with "npm install" (which works fine)? Also, would be helpful if the yarn error message had more information to identify the actual error.

@duderdice object-merge just like the other packages mentioned here (e.g. sjcl) contains a folder named License which yarn incorrectly assumes is a readable file. Once it tries to read it, EISDIR is thrown. Same happens with README directory.

This is a major blocker for us too, so I'm really hoping this issue gets resolved soon.

This is still an issue for us, I've attached the log file since I updated to the latest version and now the error message has changed to An unexpected error occured, please open a bug report...

yarn-error.log

@hassankhan The fix from #1426 is not included in v0.16.1. It has not been released yet.

Ahh right, thanks for letting me know!

Umm. I got lots of pings from this. Glad it's fixed now. Thanks and stuff!

Sad to say, this one has reared its ugly head again.

I had a file, within my project root.

simply named '1'

It was an accidental output from terminal by accidentally executing 'yarn start >1'

Breaking immediately, but forgetting about the file....

Every time I ran yarn install this would pop up.

yarn install v0.27.5
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "EISDIR: illegal operation on a directory, open '/Users/USER/Library/Caches/Yarn/v1/npm-statuses-0.0.0-44a95172-f493-4058-9e0a-8ef3065365b8-1503561458929'".
info If you think this is a bug, please open a bug report with the information provided in "/Users/USER/Repos/PROJECT/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Renamed the 1 file, and yarn worked again.

Figured you might want to know.

Thanks for the report @volure! Your message made me think that you may be encountering #4013 which is fixed on latest master. Would you like to give a try to the latest nightlies to see whether this fixes your issue? You can find the nightlies at https://yarnpkg.com/en/docs/nightly

Let us know in here or on Dicord, if you have any more trouble.

I'm using yarn nightly. All my projects with yarn are broken the same way. This is machine wide problem

yarn upgrade
yarn upgrade v1.3.2-20171227.0155
error An unexpected error occurred: "EISDIR: illegal operation on a directory, read".

Arguments: 
  /opt/nodes/8.6.0/bin/node ~/.yarn/bin/yarn.js upgrade react-snap

PATH: 
  /opt/boxen/nodenv/versions/8.6.0/bin:/opt/boxen/nodenv/libexec:~/.yarn/bin:~/.opam/system/bin:~/.cargo/bin:/usr/local/heroku/bin:bin:/opt/boxen/rbenv/shims:/opt/boxen/rbenv/bin:/opt/boxen/ruby-build/bin:/opt/boxen/nodenv/shims:/opt/boxen/nodenv/bin:/opt/boxen/node-build/bin:/opt/boxen/homebrew/bin:/opt/boxen/homebrew/sbin:/opt/boxen/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:~/.rsvm/current/dist/bin

Yarn version: 
  1.3.2-20171227.0155

Node version: 
  8.6.0

Platform: 
  darwin x64

npm manifest: 
  {
    "name": "app",
    "version": "0.1.0",
    "private": true,
    "devDependencies": {
      "highland": "^2.11.1",
      "level": "^2.0.1",
      "prettier": "^1.8.2",
      "react-scripts": "^1.0.17",
      "react-snap": "https://github.com/stereobooster/react-snap.git#jsdom",
      "readdirp": "^2.1.0",
      "s3-sync-aws": "^1.1.1",
      "sw-precache": "^5.2.0",
      "uglifyjs": "^2.4.11"
    },
    "dependencies": {
      "appcache-nanny": "^1.1.0",
      "preact": "^8.2.6",
      "preact-compat": "^3.17.0",
      "react": "^16.1.1",
      "react-dom": "^16.1.1",
      "react-helmet": "^5.2.0",
      "react-router-dom": "^4.2.2",
      "loadable-components": "^0.4.0",
      "styled-components": "^2.2.3"
    },
    "scripts": {
      "start": "react-scripts start",
      "build-react": "react-scripts build",
      "build-preact": "node scripts/build-preact.js",
      "build":
        "yarn run build-react && react-snap && yarn run generate-sw && yarn run generate-appcache",
      "test": "react-scripts test --env=jsdom",
      "eject": "react-scripts eject",
      "generate-fb": "node scripts/add-push-headers.js",
      "generate-sw":
        "sw-precache --root=build --config scripts/sw-precache-config.js && uglifyjs build/service-worker.js -o build/service-worker.js",
      "generate-appcache": "node scripts/generate-appcache.js",
      "aws-deploy": "node scripts/aws-deploy.js",
      "deploy": "yarn run build && yarn run generate-fb && firebase deploy",
      "prettier": "prettier --write {*,scripts/*,src/*}.{js,json,css}"
    },
    "reactSnap": {
      "cacheAjaxRequests": true,
      "inlineCss": true,
      "asyncScriptTags": false,
      "removeStyleTags": false,
      "http2PushManifest": true,
      "include": ["/shell.html"],
      "destination": "tmp",
      "concurrency": 1
    }
  }

yarn manifest: 
  No manifest

Lockfile: 
  # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
  # yarn lockfile v1

...

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

Ok, I found what it was. But before I found it:

  • removed all instances of yarn (brew uninstall --force yarn, brew doctor, brew cleanup)
  • I remove all .yarn.. files and folders for home directory
  • made a clean install

The error still was reproducible. Then I removed the folder with the project where I first saw this error. And the error is gone. Name of the project is package.json

wat

Deleting the yarn.lock fixed the issue for me and then yarn install

@stereobooster Yes !!!

I had the same problem : I created a project named package.json, mainly to let GitHub and Snyk alert me when a problem or vulnerability was found in my dependencies ;-)

try locating and removing the .npmrc folder that is located in c:/users/your username/.npmrc

Tive o mesmo problema, ao remover a pasta .npmrc do c:/users/seu usu谩rio/.npmrc o yarn funcionou tranquilamente.
Em outra maquina usava o npm, ent茫o migrei pro yarn, porem tive alguns problema que o npm n茫o encontrava essa pasta mesmo existindo, talvez n茫o seja uma boa ter os 2 instalados ao mesmo tempo.

Was this page helpful?
1 / 5 - 1 ratings