Cannot Use Import Statement Outside a Module: ESM vs CommonJS
Fix SyntaxError: Cannot use import statement outside a module in Node and browsers: type module, .mjs, require of ESM and __dirname in ESM.
Aditya has worked as a developer in Mumbai since 2016, about 10 years, mostly on enterprise web applications: Angular and React front ends, and Java and Spring Boot services behind them.
Education: M.Sc. in Physics, Dr. Bhimrao Ambedkar University, Agra.
Stacktrick began as Aditya's personal blog on this domain (2021 to 2024) and relaunched in September 2026 as an interview-prep site. Drafts are prepared with AI tools. Aditya chooses the topics and reviews each guide before it is published; JavaScript, TypeScript and Python examples are run, Java and Angular examples are checked against the documentation, and every guide states the versions its code targets. The editorial policy explains the process and how to report a mistake.
Fix SyntaxError: Cannot use import statement outside a module in Node and browsers: type module, .mjs, require of ESM and __dirname in ESM.
When React runs useEffect cleanup, why Strict Mode mounts twice, and how to clean up listeners, timers, sockets and fetches without leaks.
Fix Angular NG8002 Can't bind to 'ngModel' since it isn't a known property of 'input': import FormsModule, then fix formControl and inputs.
Fix TS2345 'Argument of type string is not assignable to parameter of type never' from empty arrays, function unions and exhaustive checks.
ClassNotFoundException vs NoClassDefFoundError in Java: what each error means, why classes go missing at runtime and how to fix the classpath.
Seeing the Whitelabel Error Page with status 404 in Spring Boot 3? Check the mapping, component scan, @RestController and context path.
Where async errors escape try/catch in Node.js, why a floating promise kills the process, and how to wrap causes and catch at one boundary.
NULL makes comparisons unknown, not false. See how that drops rows from WHERE, empties NOT IN and slips past CHECK constraints.
Fix Docker 'port is already allocated' and 'address already in use': find the container or process on the port, then remap or bind to 127.0.0.1.
Fix Git's error: failed to push some refs and ! [rejected] main -> main (fetch first): fetch, rebase or merge, and force-with-lease safely.
Size a URL shortener from 100M links a month, pick between counter-based and random codes, and keep a 4,000 req/s redirect path cheap.
How screen reader users jump between headings, why levels should follow structure rather than font size, and how to fix skipped levels.
48 must-know facts & snippets
From unknown to infer, on one page
Partial → Awaited, all of them
Rendering to Server Components, on one page
Every hook, one example each
Signals to guards, standalone-first
The 30 operators you'll actually use
Semantics to grid, cascade to stacking
Event loop to streams, checked on Node 22
OOP to virtual threads, on one page
Beans to JWT and @Transactional, one page
Joins to MVCC, every query run on Postgres 16
Dockerfile to Compose, layers to PID 1
Staging area to canary deploys, on one page
Big-O to DP, with Python templates
Rendering to caching, plus five mini-designs