Skip to content

web-full-stack/how-to-use-cjs-module-as-esm-module-in-node.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

how-to-use-cjs-module-as-esm-module-in-node.js

CJS => ESM

dev

# yarn
$ yarn esm
$ yarn cjs
# npm
$ npm run esm
$ npm run cjs

demo

ESM usages

import NextMdx from '@next/mdx'; // ✅
// ...
NextMdx()

OR

import * as NextMdx from '@next/mdx'; // ✅
// ...
NextMdx.default()

vercel/next.js#43665 (comment)