Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR_REQUIRE_ESM error on start #1674

Open
dangreen opened this issue Oct 28, 2021 · 22 comments
Open

ERR_REQUIRE_ESM error on start #1674

dangreen opened this issue Oct 28, 2021 · 22 comments

Comments

@dangreen
Copy link

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
Copy link
Author

gatsbyjs/gatsby#33713

@absozero
Copy link

absozero commented Nov 3, 2021

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

@tiagoalvesdulce
Copy link

+1

@fernandoabolafio
Copy link

fernandoabolafio commented Nov 10, 2021

+1

@ShrijanaCodes
Copy link

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

@drewlustro
Copy link

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

@drewlustro
Copy link

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"
}

@uuryildirim
Copy link

uuryildirim commented Nov 19, 2021

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

@markgong-gd
Copy link

+1

@fcano-ut
Copy link

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

@gmonte
Copy link

gmonte commented Jan 20, 2022

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

@Arun-kc
Copy link

Arun-kc commented Feb 18, 2022

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

@steffchep
Copy link

steffchep commented Mar 1, 2022

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.

@fcano-ut
Copy link

fcano-ut commented Mar 1, 2022

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

@steffchep
Copy link

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.

@admirhusic
Copy link

+1

@nejcm
Copy link

nejcm commented Oct 3, 2022

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"
  }

@pedronauck
Copy link
Member

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

@ParseDark
Copy link

same issue..

@dan-cooke
Copy link

dan-cooke commented Feb 8, 2023

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

@TomaszWaszczyk
Copy link

Same here.

@403-html
Copy link

403-html commented Aug 20, 2024

Hi I have the same issue, I see some ideas how to resolve, but is there some ultimate solution ETA which is on the horizon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests