kingzustin
kingzustin

Reputation: 111

Angular 2 cli - ng serve gives 'EIO: i/o error'

I'm working on building a portfolio website using Angular 2. I know there's simpler ways to go about it, but this is also a refresher for me as it's been a while since I've used Angular 2.

When I try to use 'ng serve' to run my project, it crashes and gives this: '''"An unhandled exception occurred: EIO: i/o error, read See "C:\Users...\angular-errors.log" for further details."'''

The error log just looks like any other error in code:

[error] Error: EIO: i/o error, read
at Object.readSync (fs.js:506:3)
at tryReadSync (fs.js:331:20)
at Object.readFileSync (fs.js:360:19)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:994:22)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (D:\...\portfolio-website\node_modules\webpack-dev-server\node_modules \braces\lib\utils.js:13:19)
at Module._compile (internal/modules/cjs/loader.js:959:30)

This error started happening when I reset my PC yesterday but kept my files. I still had to reinstall node and angular because windows lost the path keys (or environment variables or whatever lol)

I opened up an administrator command prompt and tried from that, and it woks fine. Is there an ownership issue with the files?

I've searched for a couple of hours and nothing is for this error, and nothing suggested is either relevant or works. Everything I'm using is up to date (unless maybe I don't realize I'm using it? I only started a few days ago)

Versions: Angular: 8.3.21 Node: 12.14.0 npm: 6.13.4

Upvotes: 3

Views: 5902

Answers (5)

Patrick Ofili
Patrick Ofili

Reputation: 1

Clone the repo newly from GitHub but instead of running npm install to create the node modules folder, use the node modules folder from the old repo.

Upvotes: 0

Veeramani
Veeramani

Reputation: 1

On Ubuntu, I had the same problem, because of disk corruption. I deleted the node_modules folder and ran npm i. Now it is working perfectly.

Upvotes: 0

mastercoder8
mastercoder8

Reputation: 67

OS: Windows 10 (64 bit) issue was caused in an expo/react-native project.

For me removing node_modules didn't solve the problem, kept trying restart, cleaning up/deframenting disk.

Installing using yarn or npm install always resulted in error An unexpected error occurred: "EIO: i/o error, read"

TL;DR Only way to resolve is by (trial & error) removing all the lock files (yarn.lock, package-lock.json) and the node_modules before doing the installation/serving.

Upvotes: 0

Ian
Ian

Reputation: 3159

Disk corruption has indeed occurred.

To fix you can just delete the node_modules folder and run npm install

Upvotes: 4

kingzustin
kingzustin

Reputation: 111

After much googling, ensuring packages were updated, and slamming my head against the desk, I solved the problem.

My hard drive has a bad sector, and my node_modules\.bin is corrupt.

I copied everything but node_modules to a new folder, then ran npm install.

Everything works now!

Upvotes: 8

Related Questions