Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

Node.js fails with uv_cwd ENOENT when its folder is gone

ErrorError: ENOENT: no such file or directory, uv_cwd

Short 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.

  • Applies to Node.js 22, npm 10, Ubuntu 24.04, macOS 15
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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"
  2. 2Match what you see, then jump to its fix

    1. 1pwd 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. 2A 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

What does the error look like?

  • Error: ENOENT: no such file or directory, uv_cwd
  • npm, 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 . && pwd

2Fix

Change to a folder that exists, usually the project folder, and run the command from there.

cd ~
cd path/to/your/project

3Verify

Node reports a working directory.

node -e "console.log(process.cwd())"

Confirmed by man7.org

Did this fix it?

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 grep

2Fix

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 dev

3Verify

The process starts and keeps running after the folder is touched.

node -e "console.log(process.cwd())"

Confirmed by nodejs.org

Did this fix it?

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

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

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.