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.

Error: Cannot find moudle "vue-awesome/components/Icon" in TypeScript template

See original GitHub issue

Hi, 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:open
  • Created 5 years ago
  • Reactions:2
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

16reactions
Vad1mocommented, Jan 7, 2019

this is kind of strange, I swapped from import Icon from "vue-awesome/components/Icon"; to import 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.

0reactions
edwhcommented, Mar 17, 2022

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:

if (process.client) {
  import('vue-awesome/icons/globe-europe')
}

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.

Read more comments on GitHub >

github_iconTop 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 >

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