question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 clear or yarn clear command.
  • * I have tried rm -rf node_modules yarn.lock package-lock.json and 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.

  1. git clone git@github.com:facebook/docusaurus.git
  2. yarn install
  3. yarn 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.1
  • node version v14.4.0
  • Ubuntu 20.04.3 LTS
  • v2.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:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
slorbercommented, Aug 20, 2021

Technically, this code is correct and is quite similar to the one documented here: https://babeljs.io/docs/en/babel-traverse

image

File is indeed a Node.

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/types and 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.

0reactions
slorbercommented, Aug 24, 2021

I guess we’ll never know 🤪 maybe when I’ll upgrade to Yarn 3

Read more comments on GitHub >

github_iconTop Results From Across the Web

Syntax error causes yarn start to exit Ā· Issue #2449 - GitHub
Accidentally introducing a syntax error in JSX code causes yarn start to exit completely. This is unexpected coming from other tools such as...
Read more >
@docusaurus/mdx-loader | Yarn - Package Manager
Fix babel/env not picking the correct browserslist configuration during development. When running docusaurus start , process.env.NODE_ENV is now consistentlyĀ ...
Read more >
MDX and React - Docusaurus
To define any custom component within an MDX file, you have to export it: only paragraphs that start with export will be parsed...
Read more >
Highest scored 'docusaurus' questions - Page 3 - Stack Overflow
Syntax error: Unexpected token ) when building Docusaurus on Node 6 ... Trying to run a project cloned from GitHub and the yarn...
Read more >
Build fails with Internal Error: website@workspace:.: This ...
To verify that the problem is in ā€œbuild stepā€ running on Netlify, I uploaded the ... nik$ yarn info ā”œā”€ @docusaurus/core@npm:2.0.0-beta.18Ā ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found