Component directory cannot be resolved
See original GitHub issueIm using CRA + TypeScript and wanted to test out playroom but immediately run into this error:
(node:39309) UnhandledPromiseRejectionWarning: Error: Cannot find module './src/Components'
playroom.config.js
module.exports = {
components: './src/Components',
outputPath: './build/playroom',
typeScriptFiles: [
'src/Components/**/*.{ts,tsx}',
'!**/node_modules',
],
};
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve"
},
"include": [
"src"
]
}
Any ideas about this? 😞
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
React cannot resolve module in my directory
Your directory path is wrong. Three dots (".../") is not a valid relative path. It should be: import '../../static/css/app_style.css'.
Read more >Cannot resolve file or directory entry.component.css
I am doing the Nesting Components part of Angular Basics, and there is one problem ... Cannot resolve file or directory entry.component.css.
Read more >TypeScript: Documentation - Module Resolution
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >Cannot resolve directory '@' error in PhpStorm with Vite
I did it like you said and restarted IDE, but I still get the same thing. this `components` directory is under ./resources/js/components.
Read more >LWC compiler cannot resolve import
If the component has missing files or invalid import statements, that is reported at the time of deploying the component. No such errors...
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
Thank you for your detailed explanation. I managed to get it running now. Seems like it was me misunderstanding the documentation. Two things that were not entirely clear to me:
components: './src/components'
it is not clear that it should point to a file containing exported components. I thought it should point to my component directory.webpackConfig
in order to include components written in TypeScript.Anyways, maybe it is just my lack of knowledge 😄 Thanks for this awesome project. Will start playing with it right now 👍
Thanks for that, makes it a lot clearer. Here is the list i worked through to get that example working:
Config issues
The
themes
andFrameComponent
are optional in the playroom config and the paths specified dont exist, so i removed these config values.The
components
path is resolved based on your webpack config. Out of the box playroom only configured react and jsx support so doing anything more than playing with react requires passing awebpackConfig
that allows playroom to run your code.Component file
This isn’t being found by webpack because it’s is not configured to resolve
ts
/tsx
extensions out of the box. You can do this by providing your own webpack config (see our typescript example).I recommend pointing at a file the exports your components, eg:
The main issue i see here is you need to provide playroom with the webpack config so it knows how to load your components.
Hope this helps.