docz: ERR_REQUIRE_ESM error on start

Bug Report

  1. yarn add -D docz react react-dom
  2. yarn docz dev
/Users/dangreen/github/react-chartjs-2/node_modules/gatsby-recipes/dist/graphql-server/server.js:52
var remarkMdx = require('remark-mdx');
                ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/dangreen/github/react-chartjs-2/node_modules/gatsby-recipes/node_modules/remark-mdx/index.js from /Users/dangreen/github/react-chartjs-2/node_modules/gatsby-recipes/dist/graphql-server/server.js not supported.
Instead change the require of index.js in /Users/dangreen/github/react-chartjs-2/node_modules/gatsby-recipes/dist/graphql-server/server.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/dangreen/github/react-chartjs-2/node_modules/gatsby-recipes/dist/graphql-server/server.js:52:17) {
  code: 'ERR_REQUIRE_ESM'
}

Environment

  • docz version: 2.3.1
  • OS: macOS 11.6
  • Node/npm version: Node 16, yarn 1

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 19
  • Comments: 21 (1 by maintainers)

Commits related to this issue

Most upvoted comments

If you’re using npm (where "resolutions" is not available), you can install this version of remark-mdx to bypass this issue:

npm install remark-mdx@2.0.0-next.9 --save-dev

I think “remark-mdx” is the problem. It work on my computer with yarn. I dont tested with npm.

"resolutions": {
    "remark-mdx": "1.6.22"
}

Env specs: node: 14.17.6 yarn: 1.22.0 npm: 6.14.15

This is happening mainly because all new packages related to Unified are ESM. The new version I’m creating right now fixes this issue 😃

Any updates on when this version will be released @pedronauck ? This library is currently unusable for modern toolchains - unfortunately have to go back to storybook

I also had some other issues after solving this one. It’s all about incompatible dependencies (@emotion/core seems to be specially problematic).

I posted in a comment how I managed to make it work (using the Gatsby docz theme, instead of docz directly).

Thanks for responding! However, an issue such as this having been open since October kind of makes me hesitant to continue my evaluation of docz at this point.

Any updates? The above solutions doesn’t work for me.

Env specs: docz: 2.3.1 node: 16.13.1 yarn: 1.22.17 npm: 8.1.2

@ShrijanaCodes – unfortunately no. I fought with this one for several hours and gave up.