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.

@mdx-js/runtime Module not found: Can't resolve '@mdx-js/runtime'

See original GitHub issue

Subject of the issue

When using MDX Runtime with NextJS, and using import MDX from @mdx-js/runtime to use the package the following error is being raised:

NOTE This error occurs after performing a yarn add @mdx-js/runtime and yarn install

Module not found: Can't resolve '@mdx-js/runtime' in '/User/path/to/project/mdx-runtime-error-nextjs/pages

This appears to be related to the upgrade from 1.5.1 to 1.5.2 as this error was not present in prior versions of @mdx-js/runtime, such as 1.5.1.

Version 1.5.2 is present in the web-app that originated this error for us, as shown in the repository below.

Comparison of changes: https://github.com/mdx-js/mdx/compare/v1.5.1...v1.5.2

Your environment

  • OS: System Version: macOS 10.14.6 (18G103); Kernel Version: Darwin 18.7.0;
  • Packages:
  "dependencies": {
    "@mdx-js/loader": "^1.5.2",
    "@mdx-js/mdx": "^1.5.2",
    "@mdx-js/react": "^1.5.2",
    "@mdx-js/runtime": "^1.5.2",
    "@next/mdx": "^9.0.3",
    "next": "^9.0.3",
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "remark-emoji": "^2.0.2",
    "remark-images": "^1.0.0"
  }
  • Env:
  1. Node: v13.2.0
  2. Yarn: 1.19.2
  3. Chrome: Version 79.0.3945.79 (Official Build) (64-bit)

Steps to reproduce

Please see the minimum viable error reproduction repository here:

Also see this Code Sandbox with a working example of the error:

Run the steps below to see the error:

  1. yarn install
  2. yarn dev
  3. Visit http:localhost:3000 to view the Index page loading correctly.
  4. Visit http:localhost:3000/hello to view the Hello page loading correctly.
  5. Visit http:localhost:3000/runtime to view the “Module not found” error.

NOTE: @mdx-js is installed within node_modules and includes the /runtime/dist directory.

Expected behaviour

The @mdx-js/runtime module is imported successfully and available for use as a component for generating dynamic React component output.

Actual behaviour

The runtime raises an error that the module cannot be resolved with the message:

Module not found: Can't resolve '@mdx-js/runtime'

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
JounQincommented, Dec 20, 2019

Sorry @Dangeranger , it should be fixed in #877, let’s wait a new patch version.

2reactions
Dangerangercommented, Dec 19, 2019

@ChristianMurphy You can see the fixed and working version at the following URLs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module '@mdx-js/mdx' - Gatsby - Stack Overflow
I'm using no MDX in my project howsoever.. npm run develop produces this issue, does someone has some knowledge about this? internal/modules/cjs ...
Read more >
@mdx-js/runtime - npm
Parse and render MDX in a runtime environment. Latest version: 1.6.22, last published: 2 years ago. Start using @mdx-js/runtime in your ...
Read more >
mdx-js/esbuild
If you want to evaluate MDX code then the lower-level compiler ( @mdx-js/mdx ) can be used. to support nonstandard JSX runtime (such...
Read more >
@mdx-js/mdx | Yarn - Package Manager
And a module to evaluate that: import fs from 'node:fs/promises' import * as runtime from 'react/jsx-runtime' import {evaluate} from '@mdx-js/mdx' const ...
Read more >
gatsby-plugin-mdx
You can find that information in their respective README. gatsby-config.js. module.exports = { plugins: [ ...
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