u/Careful-Falcon-36

ESM vs CJS — Why Your import Still Breaks in 2026 and How to Finally Fix It
▲ 4 r/node+1 crossposts

ESM vs CJS — Why Your import Still Breaks in 2026 and How to Finally Fix It

ERR_REQUIRE_ESM is still my villain in 2026 Third project this month where someone added chalk v5 or node-fetch v3 and suddenly half the codebase breaks. The thing that took me too long to internalize: its not symmetric. ESM can pull from CJS just fine, but CJS hard-blocks on ESM its not a config issue, it's by design because of how the loaders work. Also burned by the __dirname thing more times than I'd like to admit. And the dual-package hazard is completely silent no error, just two instances of the same module running and your singleton state going nowhere. Documented everything I kept hitting. Link in comments if anyone wants it.

stackdevlife.com
u/Careful-Falcon-36 — 23 hours ago
▲ 0 r/node

How I Fixed a Node.js API That Was Taking 15 Minutes to Return 8,000 Records

I was working on a Node.js API that was extremely slow — it took around 15-18 minutes to fetch 8,000 records.

The issue wasn’t Node.js itself, but how MongoDB queries and aggregations were written.

Here’s what I found and fixed:

  • Missing indexes on frequently queried fields
  • Heavy aggregation pipelines without optimization
  • Fetching unnecessary data (no projection)
  • Inefficient query structure

After optimizing indexes and rewriting aggregations, the response time dropped to 15-25 seconds.

I wrote a detailed breakdown with examples here: https://www.stackdevlife.com/blog/nodejs-mongodb-api-performance-optimization

Would love to know how others handle large dataset performance in Node.js APIs.

stackdevlife.com
u/Careful-Falcon-36 — 2 days ago
▲ 0 r/reactjs+1 crossposts

leaking in Next.js — and how to stop it

When I started working with Next.js, I made mistakes by using NEXT_PUBLIC_ for sensitive keys and overlooked it many times. Later, during a code review, I realized that such keys should not be exposed publicly.

That’s why I wrote about what’s actually leaking in Next.js — and how to stop it.

If you have any better suggestions, please let me know.

stackdevlife.com
u/Careful-Falcon-36 — 3 days ago

`any` caused a production bug for me — how are you handling API typing?

The fix wasn't complicated but it changed how I think about external data.

How are you handling API response types in your projects?

stackdevlife.com
u/Careful-Falcon-36 — 3 days ago