I was modifying an existing Angular application that I hadn't touched in a month or so and after completing the modification, I wanted to check on some of the library interdependencies that had previously been a problem. I have found that using yarn install instead of npm install does a better job of identifying these dependencies. But this time, "npm install" exited without any errors and yarn install exited with an EISDIR: illegal operation on a directory, read error. The error message is a bit vague, in that, yes it does indicate that there was a problem reading a directory, but WHICH directory?
I searched online for a solution and found numerous examples of how each person solved their problem when receiving this error, but the solutions were so "all over the place", it didn't seem as though the underlying reason was really discovered. I found little commonality in the responses and solutions provided. Some were experiencing this problem with yarn, as I had, but others thought it was a node problem. Since I was able to execute npm install without errors occurring, and experienced the error only when executing yarn, I focused on those solutions. But many of those solutions, like removing the trailing "/" from a directory name in the angular.json file, were as vague as the initial error message - which directory?
In order to isolate the problem I was experiencing I used the following steps:
- Create a totally new installation of an Angular app using the
ng new application_namecommand. - If successful, run
ng build&npm installfrom within the newly created directory. - If successful, run
yarn installfrom within the newly created directory. - If not successful, uninstall yarn using
npm uninstall -g yarn - Attempt to run
yarn installagain to verify that it has been uninstalled. - Reinstall yarn with
npm install -g yarn - Run
yarn installagain to see whether the error still occurs - Write this article and ask for help!
Here are the results:
- Create a totally new installation of an Angular app using the
ng new application_namecommand.
C:\src\Angular>ng new yarntest --style scss --routing --inline-style --inline-template
CREATE yarntest/angular.json (2949 bytes)
CREATE yarntest/package.json (1039 bytes)
CREATE yarntest/README.md (1062 bytes)
CREATE yarntest/tsconfig.json (901 bytes)
CREATE yarntest/.editorconfig (274 bytes)
CREATE yarntest/.gitignore (548 bytes)
CREATE yarntest/tsconfig.app.json (263 bytes)
CREATE yarntest/tsconfig.spec.json (273 bytes)
CREATE yarntest/.vscode/extensions.json (130 bytes)
CREATE yarntest/.vscode/launch.json (470 bytes)
CREATE yarntest/.vscode/tasks.json (938 bytes)
CREATE yarntest/src/main.ts (214 bytes)
CREATE yarntest/src/favicon.ico (948 bytes)
CREATE yarntest/src/index.html (294 bytes)
CREATE yarntest/src/styles.scss (80 bytes)
CREATE yarntest/src/app/app-routing.module.ts (245 bytes)
CREATE yarntest/src/app/app.module.ts (393 bytes)
CREATE yarntest/src/app/app.component.spec.ts (997 bytes)
CREATE yarntest/src/app/app.component.ts (1483 bytes)
CREATE yarntest/src/assets/.gitkeep (0 bytes)
√ Packages installed successfully.
warning: in the working copy of '.editorconfig', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '.gitignore', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '.vscode/extensions.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '.vscode/launch.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '.vscode/tasks.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'angular.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'package-lock.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'package.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/app/app-routing.module.ts', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/app/app.component.spec.ts', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/app/app.component.ts', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/app/app.module.ts', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/index.html', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/main.ts', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/styles.scss', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'tsconfig.app.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'tsconfig.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'tsconfig.spec.json', LF will be replaced by CRLF the next time Git touches it
Successfully initialized git.
- If successful, run
ng build&npm installfrom within the newly created directory.
C:\src\Angular>cd yarntest
C:\src\Angular\yarntest>ng build
√ Browser application bundle generation complete.
√ Copying assets complete.
√ Index html generation complete.
Initial Chunk Files | Names | Raw Size | Estimated Transfer Size
main.134180b6e8be9037.js | main | 181.44 kB | 48.93 kB
polyfills.98bad6826f486d9e.js | polyfills | 33.02 kB | 10.63 kB
runtime.023fe634ac8a8221.js | runtime | 894 bytes | 521 bytes
styles.ef46db3751d8e999.css | styles | 0 bytes | -
| Initial Total | 215.33 kB | 60.07 kB
Build at: 2024-03-18T20:49:58.769Z - Hash: b8f5805e7b85e7f0 - Time: 27323ms
C:\src\Angular\yarntest>npm install
up to date, audited 1013 packages in 3s
119 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
- If successful, run
yarn installfrom within the newly created directory.
C:\src\Angular\yarntest>yarn install
yarn install v1.22.22
error Error: EISDIR: illegal operation on a directory, read
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
- If not successful, uninstall yarn using
npm uninstall -g yarn
C:\src\Angular\yarntest>npm uninstall -g yarn
removed 1 package in 637ms
- Attempt to run
yarn installagain to verify that it has been uninstalled.
C:\src\Angular\yarntest>yarn
'yarn' is not recognized as an internal or external command,
operable program or batch file.
- Reinstall yarn with
npm install -g yarn
C:\src\Angular\yarntest>npm install -g yarn
added 1 package in 1s
- Run
yarn installagain to see whether the error still occurs
C:\src\Angular\yarntest>yarn install
yarn install v1.22.22
error Error: EISDIR: illegal operation on a directory, read
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
- Write this article and ask for help!