Unable to import components — "Could not resolve "./Cool""
See original GitHub issueThank 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.0next
version: 11.0.1react
version: 17.0.2node
version: 14.17.3npm
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:
- Created 2 years ago
- Reactions:3
- Comments:8
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 ourpeerDependency
of0.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.
I got a similar issue and it was resolved in v.5.1.1
Thanks @Arcath 👍