yarn start errors out when building '@docusaurus/mdx-loader'
See original GitHub issueš Bug Report
Prerequisites
- Iām using the latest version of Docusaurus.
- I have tried the
npm run clearoryarn clearcommand. - * I have tried
rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages. (* Entire project) - * I have tried creating a repro with https://new.docusaurus.io (*No. Cloned the repository)
- I have read the console error message carefully (if applicable)
Description
Running yarn install and then yarn start, the builder stack traces when building '@docusaurus/mdx-loader'.
At first I thought this might be me, so deleted, rinsed and repeated the clone. Same result. I also qualified what I had experienced, in Discord.
Have you read the Contributing Guidelines on issues?
Yup, I read the guidelines and followed the installation process as described, albeit direct from the repo.
Iām happy to raise a PR, as I believe I have found the type error on line 33 in packages/docusaurus-mdx-loader/src/remark/toc/index.ts.
Steps to reproduce
~Use https://new.docusaurus.io to create a CodeSandbox reproducible demo of the bug.~ I believe it is not possible to reproduce in CodeSandbox, as this is a stack trace during the build process.
git clone git@github.com:facebook/docusaurus.gityarn installyarn start
Expected behavior
lerna info run Ran npm script 'build' in '@docusaurus/mdx-loader' in 4.5s:
Actual behavior
lerna ERR! yarn run build exited 2 in '@docusaurus/mdx-loader'
lerna ERR! yarn run build stdout:
src/remark/toc/index.ts(33,12): error TS2345: Argument of type 'File' is not assignable to parameter of type 'Node | Node[] | null | undefined'.
Type 'import("/openSource/docusaurus/node_modules/@babel/parser/node_modules/@babel/types/lib/index").File' is not assignable to type 'babel.types.File'.
The types of 'program.body' are incompatible between these types.
Type 'import("/openSource/docusaurus/node_modules/@babel/parser/node_modules/@babel/types/lib/index").Statement[]' is not assignable to type 'babel.types.Statement[]'.
Type 'import("/openSource/docusaurus/node_modules/@babel/parser/node_modules/@babel/types/lib/index").Statement' is not assignable to type 'babel.types.Statement'.
Type 'BlockStatement' is not assignable to type 'Statement'.
lerna ERR! yarn run build exited 2 in '@docusaurus/mdx-loader'
Your environment
The versions of
yarn version 3.0.1node version v14.4.0Ubuntu 20.04.3 LTSv2.0.0-beta.4
Reproducible demo
Happens with yarn start
~Use https://new.docusaurus.io to create a CodeSandbox reproducible demo of the bug.~
~(Paste the link to an example repo, including a docusaurus.config.js, and exact instructions to reproduce the issue.)~
Issue Analytics
- State:
- Created 2 years ago
- Comments:5

Top Related StackOverflow Question
Technically, this code is correct and is quite similar to the one documented here: https://babeljs.io/docs/en/babel-traverse
Fileis indeed aNode.I suspect for some reason you end-up with a mismatch, maybe due to a duplicate dependency or something?
Try to run
yarn why @babel/typesand see if you have any duplicates.Also, if you use Yarn 3 PNP linker, it may be worth trying the node-modules linker instead.
But Iād just suggest using Yarn 1 for now.
Iād be happy to move to newer versions someday but we donāt officially support that today.
Going to close because Iām not sure thereās anything to do here. Let me know if you still have problems with Yarn 1, or if you succeed to make it work with Yarn 3.
I guess weāll never know 𤪠maybe when Iāll upgrade to Yarn 3