A more detailed article on ESM and CommonJS modules in Node.js
Previously, I have written some articles about different types of modules in Node.js as well as in JavaScript. I mentioned CommonJS, AMD, and even ESM modules roughly in those articles. You can revisit them in the articles "Understanding require in Node.js" and "Understanding modules in Node.js. Why are there so many module types?". However, I didn't delve deep into them. Many people wonder when to use require and when to use import. Can you use both in the same project? In today's article, let's dive into how these two types of modules work in Node.js to answer these questions...
🕝1 year ago