Skip to main content

Command Palette

Search for a command to run...

🚨 Common React & npm Bugs (and How to Fix Them Like a Pro)

Updated
4 min read
K
I am on YouTube, Facebook, TikTok, Instagram, Snapchat, dev.to, GitHub, Discord, and other platforms. Contact me at shuttle876@gmail.com and where you got my information from. I am a software engineer with 3 years of experience, looking to be able to work at a startup or top tech companies in the FAANG industry or startups. Working at startups would help solve real-world issues that would help others, or businesses.

Every developer hits weird errors. The difference between struggling for hours vs fixing things fast comes down to pattern recognition.

This post breaks down well-known bugs, why they happen, and how to fix them quickly—especially in projects using Create React App and the Node ecosystem.


🧨 1. react-scripts: command not found

❌ Error

sh: react-scripts: command not found

💥 Why it happens

  • react-scripts isn’t installed

  • node_modules is missing/corrupted

  • Wrong project directory

✅ Fix

rm -rf node_modules package-lock.json
npm install

If still broken:

npm install react-scripts

🔐 2. EACCES Permission Denied

❌ Error

EACCES: permission denied, mkdir 'node_modules/.cache'

💥 Why it happens

  • You used sudo npm install

  • Files are owned by root

✅ Fix

sudo chown -R $(whoami) .
rm -rf node_modules package-lock.json
npm install

🚫 Never use:

sudo npm install

📦 3. node_modules Hell (Corrupted installs)

❌ Symptoms

  • Random errors after install

  • Missing packages

  • App won’t start

💥 Why it happens

  • Interrupted installs

  • Lockfile conflicts

  • Cache issues

✅ Fix (golden reset)

rm -rf node_modules package-lock.json
npm cache clean --force
npm install

⚠️ 4. Version Mismatch (Node issues)

❌ Symptoms

  • Packages fail to install

  • Build crashes

  • Strange syntax errors

💥 Why it happens

Some tools don’t support newer Node versions.

✅ Fix

node -v

Use:

  • Node 18 or 20

Use a version manager if needed.


🔄 5. Mixing Package Managers

❌ Symptoms

  • Duplicate dependencies

  • Lockfile conflicts

  • Install failures

💥 Why it happens

Using npm + yarn together.

✅ Fix

  • Use ONE:

    • package-lock.json → npm

    • yarn.lock → yarn


🌐 6. Port Already in Use

❌ Error

Something is already running on port 3000

💥 Why it happens

Another process is using the port.

✅ Fix

lsof -i :3000
kill -9 <PID>

🧪 7. ESLint Permission Errors

❌ Error

EACCES: permission denied

💥 Why it happens

Same root cause: ownership issues.

✅ Fix

sudo chown -R $(whoami) .

⚡ 8. Module not found Errors

❌ Error

Module not found: Can't resolve 'xyz'

💥 Why it happens

  • Package not installed

  • Wrong import path

  • Case-sensitive file systems

✅ Fix

npm install xyz

Or fix import:

import Component from "./Component" // not ./component

🔥 9. Environment Variables Not Working

❌ Symptoms

  • process.env is undefined

💥 Why it happens

In CRA, env vars must start with:

REACT_APP_

✅ Fix

REACT_APP_API_URL=https://api.com

Restart dev server after changes.


🧠 10. Outdated Tooling Problems

❌ Symptoms

  • Random build errors

  • Slow dev server

  • Weird dependency issues

💥 Why it happens

Older tools like Create React App rely on aging dependencies.


🚀 Modern Fix (Long-Term)

Instead of constantly patching bugs:

Switch to:

  • ⚡ Vite

  • 🔥 Next.js

Example (Vite setup)

npm create vite@latest my-app
cd my-app
npm install
npm run dev

👉 Faster, fewer bugs, better DX.


🧠 Final Thoughts

Most “React bugs” are actually:

⚙️ environment problems, not code problems

Once you recognize patterns like:

  • permissions

  • missing dependencies

  • version mismatches

You’ll debug 10x faster.


💬 What bug are you stuck on?

Drop your error below 👇 I’ll help you debug it step-by-step.