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.

Unable to import components — "Could not resolve "./Cool""

See original GitHub issue

Thank you for this great library and thank you to all the contributors and example code that has got me to this point.

I am trying to get a proof of concept going, but can’t get past component importing using the cwd option.

I have tried pulling some of the example repositories as well as starting on my own from scratch. I can also reproduce the error in codesandbox.

Is there anything I’m doing incorrectly? Is there some bug in a dependency minor version somewhere? I’m stuck!

  • mdx-bundler version: 5.1.0
  • next version: 11.0.1
  • react version: 17.0.2
  • node version: 14.17.3
  • npm version: 6.14.13

Relevant code or config

export const getSinglePost = async (slug) => {
  const source = getSourceOfFile(slug);
  const directory = path.join(POSTS_PATH, slug);

  console.log("cwd", directory);

  const { code, frontmatter } = await bundleMDX(source, {
    cwd: directory
  });

  return {
    frontmatter,
    code
  };
};

What you did: Imported a component in the same directory as the .mdx file.

What happened: Got an error,

Error: Build failed with 1 error:
_content/blog/cool/_mdx_bundler_entry_point.mdx:10:17: error: Could not resolve "./Cool"

Reproduction repository: https://codesandbox.io/s/peaceful-violet-5oe07?file=/lib/data/posts.js&initialpath=/blog/cool

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:8

github_iconTop GitHub Comments

3reactions
Arcathcommented, Jul 19, 2021

Using 5.1.1 my esbuild has fallen all the way back to 0.8.57 based on the requirements of https://github.com/fal-works/esbuild-plugin-global-external Not sure why our peerDependency of 0.11.x || 0.12.x isnt throwing an issue here.

I’ve opened a PR to sort this hopefully. https://github.com/fal-works/esbuild-plugin-global-externals/pull/3

I am assuming this is the problem as my site now has the same fault after moving from 4.x to 5.x.

2reactions
phatnhsecommented, Jul 26, 2021

I got a similar issue and it was resolved in v.5.1.1

Thanks @Arcath 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't resolve module (not found) in React.js - Stack Overflow
It seems you need import Header from './components/header/header' w/o src. File path is relative to importing file path. Then you need to export ......
Read more >
react-imported-component - npm
I will import your component, and help to handle it. Latest version: 6.5.3, last published: a year ago. Start using react-imported-component ...
Read more >
Module not found: Can't resolve 'styled-components'
To solve the error "Module not found: Error: Can't resolve 'styled-components'", make sure to install the styled-components package by opening your terminal ...
Read more >
module not found error | can not resolve react dom module
Join this channel to get access to perks:https://www.youtube.com/channel/UCoSpmr2KNOxjwE_B9ynUmig/joinMy GearCamera ...
Read more >
Build a component library with React and TypeScript
When you come across these awesome tools and libraries, have you ever wondered how they are made? Or what it would take to...
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