ProjectStack
npm

npm ERR! code ENOENT — no such file or directory

npm couldn't find a file or directory it expected to exist. This most often means package.json is missing or you're running npm from the wrong directory.

Common causes

  • You're not in the project root directory where package.json lives
  • package.json was deleted or never created
  • The node_modules folder or a specific package file is missing
  • A script in package.json references a file path that doesn't exist

How to fix it

  1. Make sure you're in the right directory: ls package.json
  2. Initialize a new package.json if it's missing: npm init -y
  3. Reinstall dependencies if node_modules is missing: npm install
  4. Check the exact path mentioned in the error and verify it exists

Example

npm ERR! code ENOENT npm ERR! syscall open npm ERR! path /home/user/project/package.json npm ERR! errno -2 npm ERR! enoent ENOENT: no such file or directory, open '/home/user/project/package.json'

Running npm install from a directory that doesn't contain a package.json

Have a different error?

Paste any error message into the Error Translator to get an instant explanation.