The ENOCWD error occurs when npm can't access your current working directory because it has been deleted, moved, or renamed while your terminal session was still open. Fix it by navigating to a valid directory.
This error means that npm tried to execute a command in your current working directory, but the directory path is no longer valid or accessible. This typically happens when a folder is deleted or renamed by another process (file manager, script, or another terminal) while you still have an active shell session in that directory. Your shell session retains the old directory path in memory, but when npm tries to verify the directory exists, it fails because the path is now invalid. The operating system returns an ENOCWD (Error: NO Current Working Directory) error code.
First, check what directory your terminal thinks it's in and confirm whether it still exists:
pwdThis will print the current working directory path. If the output shows a path that doesn't exist (e.g., /home/user/my-deleted-project), the directory has been removed.
Change to a directory that definitely exists. Start with your home directory:
cd ~Or navigate to your projects folder:
cd /path/to/your/projectsRun pwd again to confirm you're in a valid location. The command should succeed without errors.
If the error persists, close the current terminal and open a new one. This forces your shell to start in a default directory (usually your home directory) rather than retaining the old invalid path:
# Close current terminal, then open a new one
# In the new terminal, verify location:
pwd
lsIf you're using VS Code or another IDE with an integrated terminal, close that terminal pane and open a new one.
If you accidentally deleted your project, you can recreate it. First check if you have a backup or version control:
# If you have a git remote, clone it back
git clone <your-repository-url> my-project
cd my-project
# Or recreate the directory structure manually
mkdir -p /path/to/your/project
cd /path/to/your/projectOnce you're in a valid project directory, npm commands should work normally.
This error is particularly common in development environments where multiple processes interact with the file system. If you're working in a Docker container, ensure your Dockerfile properly sets the WORKDIR before running npm commands. On Windows with WSL, ensure the mounted directories haven't been unmounted. For CI/CD pipelines, verify that cleanup scripts don't remove the working directory while jobs are still running.
npm ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"
npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name: tag names cannot contain spaces
How to fix "npm ERR! code EINVALIDTAGNAME - tag names cannot contain spaces"
npm ERR! code E400 npm ERR! 400 Bad Request
How to fix "npm ERR! code E400 - 400 Bad Request" error