error Error: ENOENT: no such file or directory, copyfile '.../@types/graceful-fs/index.d.ts' -> '.../node_modules/@types/graceful-fs/index.d.ts'
Nguyễn Quang Minh
Lỗi bạn gặp là:
error Error: ENOENT: no such file or directory, copyfile '.../@types/graceful-fs/index.d.ts' -> '.../node_modules/@types/graceful-fs/index.d.ts'
✅ Nguyên nhân
Lỗi ENOENT: no such file or directory
từ Yarn nghĩa là nó không tìm thấy file trong cache khi cố gắng cài đặt gói @types/graceful-fs
.
Điều này thường xảy ra do:
Cache Yarn bị lỗi hoặc thiếu file
Thư mục node_modules/các liên kết symbolic link bị hỏng (đặc biệt trên môi trường dual-boot hoặc WSL)
Gói bị cài dở dang trước đó
✅ Cách khắc phục
🧹 1. Xóa cache của Yarn
yarn cache clean
🧽 2. Xóa toàn bộ node_modules
và lockfile
rm -rf node_modules
rm yarn.lock
(Nếu dùng Windows PowerShell: Remove-Item -Recurse -Force node_modules
, hoặc xoá bằng Explorer.)
🔁 3. Cài lại từ đầu
yarn install
🧪 4. Nếu vẫn lỗi, thử cài lại gói bị lỗi trực tiếp
yarn add @types/graceful-fs --dev
🛠️ Nếu vẫn không được:
Kiểm tra quyền ghi/đọc ổ đĩa: nếu project nằm trong
/mnt/e/
(ổ đĩa mount từ Windows → Linux), đôi khi Yarn gặp vấn đề quyền (đặc biệt trong WSL hoặc Docker).
👉 Thử copy project vào thư mục nội bộ WSL:/home/your-user/project
rồi chạy lại.
✅ Tóm lại:
yarn cache clean
Xóa
node_modules
,yarn.lock
yarn install
lạiNếu vẫn lỗi → kiểm tra thư mục mount như
/mnt/e/
→ move vào/home
Cần mình gửi script tự động hóa các bước trên không?
Nguyễn Quang Minh
Passionate developer and writer sharing insights about technology, programming, and digital innovation. Follow for more content about web development and tech trends.