2coffee.dev

  • A more detailed article on ESM and CommonJS modules in Node.js
    • esm
    • commonjs
    • modules

    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

  • Understanding Modules in Node.js. Why are there so many types of modules?
    • module
    • javascript
    • node.js

    Understanding Modules in Node.js. Why are there so many types of modules?

    When building Vue.js or React.js applications, you often use the import syntax to use a component or module. However, with plain JS Node.js applications, you typically use require. Or sometimes you may come across the case where modules are declared using AMD (Asynchronous Module Definition) syntax as shown below. From these examples, have you ever wondered why sometimes you can use import, sometimes use require, or even why you can't use import syntax normally when starting a Node.js application...

    4 years ago

  • Premium
    Hello

    Me & the desire to "play with words"

    Have you tried writing? And then failed or not satisfied? At 2coffee.dev we have had a hard time with writing. Don't be discouraged, because now we have a way to help you. Click to become a member now!

    Have you tried writing? And then failed or not satisfied? At 2coffee.dev we have had a hard time with writing. Don't be discouraged, because now we have a way to help you. Click to become a member now!

    View all