Why is mixing CommonJS and ES modules a mistake?
Because they have different semantics and mixing them incorrectly causes errors. Pick one module system and use it consistently. Most Node.js projects use CommonJS (require), though ES modules (import) are now supported.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Common Mistakes When Using JavaScript on the Server
Because Node.js runs JavaScript on a single thread, so a blocking operation stops all requests. Always use async APIs in production and offload heavy synchronous work to worker threads or separate processes.
Because committing secrets to git exposes them to anyone with repo access. Use environment variables with dotenv so secrets live in .env files that are gitignored, never in code.
Expecting browser APIs like document, window, or fetch to exist. Node.js has a different environment with different APIs like fs, http, and process. Understand what is and is not available before writing server code.
Still have questions?
Browse all our FAQs or reach out to our support team
