carbon-components-vue
carbon-components-vue copied to clipboard
<cv-file-uploader> Failed to resolve import
Failed to resolve import
Detailed description
Describe in detail the issue you're having.
CvFileUploader throws error when used in my project. The error is "Failed to resolve import", which is related to CvForm component import in the file-uploader component.
In my env.d.ts I have declared the path as "declare module '@carbon/vue/src/components/*'", and I tried with different variations as well.
Still getting error:
What works for me is to modify the CvFileUploader component and remove the CvForm wrapper inside, but of course that's not permanent solution.
Any recommendation? Is this a bug?
Is this a feature request (new component, new icon), a bug, or a general issue? issue
Is this issue related to a specific component? CvFileUploader
What did you expect to happen? What happened instead? What would you like to see changed? Expected the component to load, instead it throws error.
What browser are you working in? Edge
What version of the Carbon Design System are you using? 3.0.12
What offering/product do you work on? Any pressing ship or release dates we should be aware of?
Steps to reproduce the issue
- Step one
- Step two
- Step three
- etc.
Additional information
- Screenshots or code
- Notes
The problem seems to move to next line if I modify it to use parent directory path (instead of current directory) for the import
Hmm I cannot reproduce this. I think you are correct that its may have something to do with 'env.d.ts' file. What happens if you remove the "declare module " statement?
@davidnixon Error remained even after removal of all declarations from "env.d.ts". It wouldn't be a solution anyway because without declarations the code would fail to compile from typescript.
I also must say that I use there practically all carbon components, and cv-file-uploader is the only one having this issue.
This issue has been marked as stale because it has required additional info or a response from the author for over 14 days. When you get the chance, please comment with the additional info requested. Otherwise, this issue will be closed in 14 days.
Not sure what more should I include in my response. The problem still persists as described.
I only managed to avoid the problem by having a modified copy of CvFileUploader component, where I have removed the CvForm wrapper. As mentioned, other carbon components work for me as expected.
I do not think I fully understand the use case but I think I do see the issue. Several index files import like this:
import CvForm from './CvForm';
Notice the lack of ".vue" extension! I updated those places to import like this:
import CvForm from './CvForm.vue';
Could you try this patch? carbon-vue-3.0.16-5f775.tgz
npm remove @carbon/vue
npm add ./carbon-vue-3.0.16-5f775.tgz
Another possible fix. Can you remove "declare module '@carbon/vue/src/components/*'"? I think maybe your use case is related to an issue @OlkaB resolved in April. #1578 which nows allow you to import individual components. So this should work without the declare module.
import { CvFileUploader } from '@carbon/vue';
@davidnixon I confirm, the CvFileUploader component worked as expected while using carbon-vue-3.0.16-5f775.tgz
This issue has been marked as stale because it has required additional info or a response from the author for over 14 days. When you get the chance, please comment with the additional info requested. Otherwise, this issue will be closed in 14 days.
Fixed in #1606