🔧 Error Fixes

Fix: npm ERR! ENOENT — no such file or directory


npm ERR! enoent ENOENT: no such file or directory, open '/path/to/package.json'

npm can’t find a file it needs — usually package.json or something in node_modules.

Fix 1: You’re in the wrong directory

# ❌ Running npm install in the wrong folder
pwd  # Check where you are

# ✅ Navigate to the project root (where package.json is)
cd my-project
npm install

Fix 2: package.json doesn’t exist

# Create one
npm init -y

Fix 3: Corrupted node_modules

# Nuclear option — delete and reinstall
rm -rf node_modules package-lock.json
npm install

Fix 4: Missing file referenced in package.json

Check that the "main" or "bin" field in package.json points to a file that exists:

{
  "main": "dist/index.js"
}

If dist/ doesn’t exist, run your build first: npm run build.

Fix 5: npm cache issue

npm cache clean --force
npm install

See also: npm cheat sheet | Cannot find module fix