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-scriptsisnβt installed -
node_modulesis 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.envis 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.
Top comments (0)