nodejs.dev icon indicating copy to clipboard operation
nodejs.dev copied to clipboard

Docs suggest no support for ES modules

Open binyamin opened this issue 3 years ago • 3 comments

Some of the /learn docs assume that the user can only use CommonJS imports/exports. For example:

Another difference is that Node.js uses the CommonJS module system, while in the browser we are starting to see the ES Modules standard being implemented.

In practice, this means that for the time being you use require() in Node.js and import in the browser. — Differences between Node.js and the Browser

My understanding is that both platforms supports either format. Additionally, each platform uses CommonJS unless told otherwise. Is this an oversight?

binyamin avatar Dec 16 '21 18:12 binyamin

Hey, @binyamin, this text was created before ESM release which is quite fresh feature in Node.js. If you would like to update this page with relevant info - PRs are welcome!

rodion-arr avatar Dec 17 '21 15:12 rodion-arr

hey @rodion-arr I would like to work on this issue if it is still open.

shikhar13012001 avatar Jan 01 '22 19:01 shikhar13012001

@shikhar13012001 go ahead.

binyamin avatar Jan 02 '22 13:01 binyamin