Node.js fails with uv_cwd ENOENT when its folder is gone
Error: ENOENT: no such file or directory, uv_cwdShort answer
uv_cwd is how Node.js asks the operating system for its current working directory. ENOENT means that directory no longer exists. It was deleted, usually while a terminal or a long-running process was still inside it. Change into a folder that exists and run the command again, or restart the process from the right place.
Fix it fast
1Find out which cause you have
Ask the shell where it is. If this fails or prints a path that no longer exists, the working directory was removed.
pwd; ls -ld "$PWD"2Match what you see, then jump to its fix
- 1
pwd or ls -ld on the current folder fails, or the folder is gone from the file managerThe terminal is inside a folder that was deletedFix - 2
A dev server or watcher worked, then died with the error right after something removed the project folderA running process lost its folder (clean script or removed project)Fix
- 1
What does the error look like?
Error: ENOENT: no such file or directory, uv_cwdnpm, node or next fails at start in a terminal whose folder was removed
Cause 1 of 2
The terminal is inside a folder that was deleted
1Check
The POSIX call behind this fails with ENOENT when the current working directory has been unlinked.
cd . && pwd2Fix
Change to a folder that exists, usually the project folder, and run the command from there.
cd ~
cd path/to/your/project3Verify
Node reports a working directory.
node -e "console.log(process.cwd())"Confirmed by man7.org
Cause 2 of 2
A running process lost its folder (clean script or removed project)
1Check
process.cwd() returns the working directory of the process, and the call underneath fails with ENOENT once that directory has been unlinked. So a process whose folder was removed cannot ask for its location any more.
ps aux | grep -E "node|next" | grep -v grep2Fix
Stop the old process, then start it again from the new folder.
# stop the old process by its PID from the ps output
kill <pid>
cd path/to/your/project
npm run dev3Verify
The process starts and keeps running after the folder is touched.
node -e "console.log(process.cwd())"Confirmed by nodejs.org
How do I stop it coming back?
- Do not delete or move a project folder while a terminal, editor task or dev server is running inside it.
- Stop the dev server before running a clean step that removes the folder it started in.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Web apps
npm start runs, but the browser does not refresh when you save a file
Saving a file does nothing while npm start is running
The watcher behind npm start is not seeing your edit.
4 causes, each with a fixWeb apps
django-tailwind cannot find the npm executable (cPanel, Windows, Linux)
CommandError raised by the tailwind management command about npm
django-tailwind runs npm as a subprocess, and Python sometimes cannot find it.
3 causes, each with a fixWeb apps
Playwright cannot open a headed browser on a Linux server or in Docker
npx playwright test --headed shows no window on a Linux server
A headed browser needs a display, and a Linux server or container has none.
3 causes, each with a fixWeb apps
The shell says pnpm: command not found
npx next dev works, but pnpm dev or pnpm install is not found
The shell cannot find a pnpm executable on PATH.
3 causes, each with a fixWeb apps
Vite build stops with [vite:load-fallback] Could not load a file
ENOENT: no such file or directory
The message names two files: the one Vite could not read and the file that imports it.
2 causes, each with a fixWeb apps
tsconfig rejects allowImportingTsExtensions
An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly
allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.
2 causes, each with a fix