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.

Could not find one or more icon(s) in VueJS with TypeScript

See original GitHub issue

Hi all,

I am quite new to Vuejs so my explanation may not be accurate or dumb but please understand me 😃

So I have followed the instruction and can see it’s going but only with one icon from the example but anything else keep saying ‘Could not find…’

inside main.ts

import { library } from '@fortawesome/fontawesome-svg-core';
import { faUserSecret } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
library.add(faUserSecret)
Vue.component('font-awesome-icon', FontAwesomeIcon);

inside my component,

<font-awesome-icon :icon="['fas', 'envelope-open-text']" />
<font-awesome-icon :icon="['fas', 'user-secret']" />

envelope is where I am getting an error. Based on those link Envelope User-Secret

For Envelope is

<i class="fas fa-envelope-open-text"></i>

and User-Secret is

<i class="fas fa-user-secret"></i>

So I thought I could put ‘fas’ as a prefix, then put ‘envelope-open-text’ without fa, just like what ‘user-secret’ is like. I am getting an ‘user-secret’ icon without an issue but everything else is not coming up.

Am I missing something?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

26reactions
SnowNooDLecommented, Jan 9, 2020

NVM, I just sorted out, just in case if someone else is getting the same issue, here is the solution in ReadME.md, saying put this inside main.js or main.ts

import { library } from '@fortawesome/fontawesome-svg-core';
import { faUserSecret } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
library.add(faUserSecret)
Vue.component('font-awesome-icon', FontAwesomeIcon);

You don’t really have to this unless you need those for globally, if you think you will need to use FontAwesome in multiple components, then just keep

import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
Vue.component('font-awesome-icon', FontAwesomeIcon);

then inside the componenet where you want to use,

<script lang="ts">
// this is must have
import { library } from '@fortawesome/fontawesome-svg-core';
// import { name of your icon in camelCase } from "@fortawesome/free-solid-svg-icons";
// For example, I want to use fa-enveloper-open-text, then it's faEnvelopeOpenText
import { faEnvelopeOpenText } from "@fortawesome/free-solid-svg-icons";
// Then add it to library
library.add(faEnvelopeOpenText)
</script>

// Finally I can use envelope-open-text like this inside template
<font-awesome-icon :icon="['fas', 'envelope-open-text']" />

9reactions
dohyung97022commented, May 29, 2022

I had the exact same problem with vue 3.2.13

Solved it a different way.

main.ts

import {FontAwesomeIcon} from "@fortawesome/vue-fontawesome";
import {library} from "@fortawesome/fontawesome-svg-core";
import {fas} from "@fortawesome/free-solid-svg-icons";

library.add(fas)

createApp(App)
    .use(router)
    .component('font-awesome-icon', FontAwesomeIcon)
    .mount('#app')

and added this in the component with no imports.

<font-awesome-icon icon="trash" />

The problem was that the font-awesome website keeps giving
<font-awesome-icon icon="fa-solid fa-trash" /> this instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue.js - fontawesome error "Could not find one or more icon"
When non specified, fas prefix is assumed. CodeSandbox: https://codesandbox.io/s/6j833qp57k · Share.
Read more >
fontawesome 5 could not find one or more icon in vue js ...
The icon for user has not been imported, but the one for coffee has been instead. You need to use: import { faUser...
Read more >
Could not find one or more icon(s) Warning with vuejs ...
I am unable to fix the warning “Could not find one or more icon(s) {prefix: “far”, iconName: “square”} {}” (screenshot attached)
Read more >
Font Awesome icons in Vue.js apps: A complete guide
The Font Awesome icon collection is a library of free, easy-to-use icons. In this tutorial, learn to add those icons to your Vue.js...
Read more >
@fortawesome/vue-fontawesome - npm
@fortawesome/vue-fontawesome. TypeScript icon, indicating that this package has built-in type declarations.
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