5

day 2 of still not knowing how to mix ES modules with commonjs on a node project

Comments
  • 3
    i used to just put type module in package.json. Think you have to change all imports then though to use the other Syntax. Or us .mjs files.
  • 5
    you don't. Add "type": "module" to your package.json and forget about cjs for good. cjs is a legacy thing that was needed while ECMAScript standard still had no imports. It has them now. ES Modules work in browsers without webpack or other garbage. It's the standard now, works everywhere including node, deno and bun
  • 9
  • 1
    Just GPT it
    It is usually really good at these kind of things, as long as you double check the solution
  • 4
    @kiki ...is the only correct answer.
  • 2
    @ojt-rant joewilliams unedited answer*
  • 0
    @ojt-rant but flacidDev and his 8 loyal follows (or clone accounts so he can feel better about himself) continue to claim iTs PoSsIBLe

    again (though a rare occassion), I agree with kiki
  • 0
Add Comment