Error: Cannot find moudle "vue-awesome/components/Icon" in TypeScript template
See original GitHub issueHi, firstly thank you very much for your great work. I’m new to the Vue world, so I’m not sure if it’s a real issue or I’m missing something trivial. I aplogize in advance. I’ve set the traspileDependency in vue.config.js as per READ.ME ( I’m using vue-cli 3)
// vue.config.js
module.exports = {
transpileDependencies: [
/\bvue-awesome\b/
]
}
and I’m able to correctly import and use the icons in components where the script language is plain ES6 javascript, but when I try to import the component in a TypeScript block (like this
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import Icon from "vue-awesome/components/Icon";
@Component
export default class HelloWorld extends Vue {
@Prop() private msg!: string;
}
</script>
) the build fails with the error mentioned in the title. I suspect it depends on the tsconfig.json file which somehow overrides the traspileDependency option in vue.config.js (
// tsconfig.json
{
"compilerOptions": {
.
.
.
},
"lib": [
.
.
.
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules" // <<<---------
]
}
)
How can I address this issue?
Thank you very much
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:11 (3 by maintainers)
Top Results From Across the Web
VSCode showing "cannot find module" TS error for .vue ...
In your project workspace, bring up the command palette with Ctrl + Shift + P (macOS: Cmd + Shift + P). · Type...
Read more >Error: cannot find module [Node npm Error Solved]
In my case, I got it like this "Module not found: Error: Can't resolve 'react-icons/fa' in 'C:\Users\user\Desktop\Projects\Address ...
Read more >vue-awesome
Vue -Awesome an SVG icon component for Vue.js, with built-in icons courtesy of Font Awesome. Check out the demo here.
Read more >Icon Fonts
Icon Fonts. Vuetify comes bootstrapped with support for Material Design Icons, Material Icons, Font Awesome 4 and Font Awesome 5. By default, ...
Read more >React | Font Awesome Docs
Font Awesome now has an official React component that's available for a friction-less way to use our icons in your React applications.
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 Free
Top 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
this is kind of strange, I swapped from
import Icon from "vue-awesome/components/Icon";
toimport Icon from "vue-awesome/components/Icon.vue";
in my main.ts file and it didn’t produce the error anymore…No need to change
tsconfig.json
.So this postfix is the only tiny thing needed for the plugin to work with TS.
I had same issue. I’m trying to move the import out of a Nuxt plugin into an individual Vue component to reduce bundle sizes for icons which are rarely used.
This looks promising to me:
i.e. don’t try to do this inside the SSR.
But I think that only works if you do the import inside the page, rather than any components below it. This makes it awkward, because there’s no easy way to keep track of all the icons which are used in the component tree below the page.
I’ve not found a way (yet) of importing into a component file. Or playing the async import trick.