简体   繁体   中英

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

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!

Disk corruption has indeed occurred.

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

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.

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.

从 GitHub 克隆新的存储库,但不要运行 npm install 来创建节点模块文件夹,而是使用旧存储库中的节点模块文件夹。

I had the same issue while using angular 6 cli. Before getting this error I placed an image in the assets folder but it was still throwing 404 not found. I deleted that image and surprisingly the error was gone.

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