docz icon indicating copy to clipboard operation
docz copied to clipboard

ERR_REQUIRE_ESM error on start

Open dangreen opened this issue 2 years ago • 21 comments

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

dangreen avatar Oct 28 '21 10:10 dangreen

https://github.com/gatsbyjs/gatsby/issues/33713

dangreen avatar Oct 28 '21 10:10 dangreen

I have this issue as well, running the same versions of the environment as @dangreen is, except I am using windows 10.

absozero avatar Nov 03 '21 07:11 absozero

+1

tiagoalvesdulce avatar Nov 09 '21 13:11 tiagoalvesdulce

+1

fernandoabolafio avatar Nov 10 '21 12:11 fernandoabolafio

I am running into this issue as well. Are there any workarounds?

ShrijanaCodes avatar Nov 11 '21 15:11 ShrijanaCodes

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

drewlustro avatar Nov 12 '21 01:11 drewlustro

Wow, I may have just got Node 15 working.

Here are the required package upgrades / resolutions:

"devDependencies": {
  "babel-preset-gatsby": "0.12.3"
}

"dependencies": {
  "node-sass": "5.0.0",
  "gatsby-plugin-sass": "3.0.0"
}

"resolutions": {
  "node-sass": "5.0.0",
  "**/node-sass": "5.0.0",
  "**/sharp": "0.29.2",
  "sass-loader": "10.0.5",
  "**/sass-loader": "10.0.5"
}

drewlustro avatar Nov 12 '21 01:11 drewlustro

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

uuryildirim avatar Nov 19 '21 14:11 uuryildirim

+1

markgong-gd avatar Jan 06 '22 02:01 markgong-gd

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

npm install [email protected] --save-dev

fcano-ut avatar Jan 18 '22 12:01 fcano-ut

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

gmonte avatar Jan 20 '22 20:01 gmonte

I too am facing this same issue. Is there any workaround for this?

Arun-kc avatar Feb 18 '22 13:02 Arun-kc

Same issue here. So much for quickly trying this thing out to see if it is what I need... (fresh project set up as of yesterday, via create-react-app and then installing docz, following the documentation. Using npm)

Manually installing the above mentioned version of remark-mdx fixes it partially. docz dev starts, but with a Gatsby error regarding require() of ES modules not being supported. Thus, generating development bundle fails, and the server delivers a blank page with a common.js error in the console.

Windows 10, node 16.3.0, npm 8.5.0

So... Storybook it is.

steffchep avatar Mar 01 '22 07:03 steffchep

Same issue here. So much for quickly trying this thing out to see if it is what I need... (fresh project set up as of yesterday, via create-react-app and then installing docz, following the documentation. Using npm)

Manually installing the above mentioned version of remark-mdx fixes it partially. docz dev starts, but with a Gatsby error regarding require() of ES modules not being supported. Thus, generating development bundle fails, and the server delivers a blank page with a common.js error in the console.

Windows 10, node 16.3.0, npm 8.5.0

So... Storybook it is.

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).

fcano-ut avatar Mar 01 '22 08:03 fcano-ut

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.

steffchep avatar Mar 01 '22 10:03 steffchep

+1

admirhusic avatar May 27 '22 09:05 admirhusic

I managed to fix this with the code below. The issue is some packages are not compatible and for each error given I had to find the one that is. The gatsby-recipes error was coming from node_modules/gatsby-cli on my side. Now this might not be the same for all. So you can also try downgrading the gatsby-recipes package inside resolutions. Good luck

"resolutions": {
    "babel-eslint": "10.1.0",
    "eslint": "7.19.0",
    "gatsby-cli": "^3.14.2"
  }

nejcm avatar Oct 03 '22 12:10 nejcm

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

pedronauck avatar Oct 03 '22 23:10 pedronauck

same issue..

ParseDark avatar Dec 30 '22 09:12 ParseDark

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

dan-cooke avatar Feb 08 '23 12:02 dan-cooke

Same here.

TomaszWaszczyk avatar Apr 11 '24 22:04 TomaszWaszczyk