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 v2: import URL causes fail to compile error

See original GitHub issue

Subject of the issue

The import {URL} from 'url' line in recma-document plugin creates a compile error.

I don’t think it’s necessary to import the URL class since it’s a global object?

Your environment

  • OS: Window 10 64bit
  • Packages: v.2.0.0.rc
  • Env: yarn v1.22.15 Next 11.0.1

Steps to reproduce

yarn build a nextjs project.

Expected behaviour

Project compiles.

Actual behaviour

Failed to compile due to error.

./node_modules/@mdx-js/mdx/lib/plugin/recma-document.js
Attempted import error: 'URL' is not exported from 'url' (imported as 'URL').

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
xHomucommented, Nov 10, 2021

I worked on the problem a bit more overnight and figured out the problem was caused by the version of nextjs I was using.

The compile error clears when I changed the next package from "next": "v11.0.1" to "next": "latest".

1reaction
cesutherlandcommented, Jan 31, 2022

OK, in my case this is related to some project importing node-url, and this issue: https://github.com/defunctzombie/node-url/issues/53, https://github.com/defunctzombie/node-url/issues/37 URL not exported.

URL should be available as a global and I don’t understand the comment about TS in that regard, but this trouble is on my end.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Attempted import error: 'URL' is not exported from 'url ... - GitHub
I am receiving this error when building my Next.js website using next build . ./node_modules/@mdx-js/mdx/lib/plugin/recma-document.js ...
Read more >
Next.js MDX blog post not building due to module not found ...
My Next.js project is failing to build on Vercel. I have a BlogAuthor.tsx file as so: import Avatar from "../../Common/Avatar/Avatar" ...
Read more >
Troubleshooting MDX
The reason for this error is that the parser is expecting a JavaScript import or export statement. If you want the word import...
Read more >
Parcel
$ parcel index.html Server running at http://localhost:1234 Build failed. @parcel/core: Cannot resolve 'ract' from './index.js' /dev/app/index.js: ...
Read more >
[Support Guide] Netlify app builds locally but fails on deploy ...
The build seems to be failing on an import line in one of my JS files, but running all the same commands locally,...
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