9/22/2021, 8:32:13 PM
There are few things more disheartening than when you are in the middle of a task, you run npm install
or yarn
, and everything goes to pieces – your working directory's node_modules/
are fubar'd, and no amount of running npm install
or yarn
will make it go away.
Maybe your error looks something like this:
node:events:371
throw er; // Unhandled 'error' event
^
Error: EISDIR: illegal operation on a directory, read
Emitted 'error' event on ReadStream instance at:
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -21,
code: 'EISDIR',
syscall: 'read'
}
In my case, I had been running an npm install
command when the process was killed (it was being run as part of a test suite and the test timed out, thus killing the process). It left node_modules/
in a usable state, so I didn't even think this was the cause when the next time I ran yarn
, and things went sideways quickly.
Keep calm™, and do the following, trying yarn
or npm
again in between to see if it fixes
rm yarn.lock
or rm package-lock.json
yarn cache clean
or npm cache clean
node_modules/
and start freshgit clone
againHopefully one of the above steps will get you going again.
Happy hacking!