Getting error when trying to use Nuxt font awesome 5 although I followed the official manual page
I'm trying to use font awesome 5 in my Nuxt project following the official guide below.
https://www.npmjs.com/package/nuxt-fontawesome
However, I'm getting a strange error and can't display what I want.
[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.
Here is how my code looks like:
//index.vue
<template>
<fa :icon="fas.faAddressBook" />
<fa :icon="faGithub" />
</template>
<script>
import { fas } from '@fortawesome/free-solid-svg-icons'
import { faGithub } from '@fortawesome/free-brands-svg-icons'
computed: {
fas () {
return fas
},
faGithub () {
return faGithub
}
},
and more.....
//nuxt.config.js
modules: [
[
'bootstrap-vue/nuxt', { css: true },
['nuxt-fontawesome', {
component: 'fa',
imports: [
//import whole set
{
set: '@fortawesome/free-solid-svg-icons',
icons: ['fas']
},
]
}]
],
],
fontawesome: {
component: 'fa',
imports: [
{
set: '@fortawesome/free-solid-svg-icons',
icons: ['fas']
},
],
},
Please let me ask for your help. I have spent long enough time on this issue already. Thank you in advance!
javascript nuxt
add a comment |
I'm trying to use font awesome 5 in my Nuxt project following the official guide below.
https://www.npmjs.com/package/nuxt-fontawesome
However, I'm getting a strange error and can't display what I want.
[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.
Here is how my code looks like:
//index.vue
<template>
<fa :icon="fas.faAddressBook" />
<fa :icon="faGithub" />
</template>
<script>
import { fas } from '@fortawesome/free-solid-svg-icons'
import { faGithub } from '@fortawesome/free-brands-svg-icons'
computed: {
fas () {
return fas
},
faGithub () {
return faGithub
}
},
and more.....
//nuxt.config.js
modules: [
[
'bootstrap-vue/nuxt', { css: true },
['nuxt-fontawesome', {
component: 'fa',
imports: [
//import whole set
{
set: '@fortawesome/free-solid-svg-icons',
icons: ['fas']
},
]
}]
],
],
fontawesome: {
component: 'fa',
imports: [
{
set: '@fortawesome/free-solid-svg-icons',
icons: ['fas']
},
],
},
Please let me ask for your help. I have spent long enough time on this issue already. Thank you in advance!
javascript nuxt
add a comment |
I'm trying to use font awesome 5 in my Nuxt project following the official guide below.
https://www.npmjs.com/package/nuxt-fontawesome
However, I'm getting a strange error and can't display what I want.
[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.
Here is how my code looks like:
//index.vue
<template>
<fa :icon="fas.faAddressBook" />
<fa :icon="faGithub" />
</template>
<script>
import { fas } from '@fortawesome/free-solid-svg-icons'
import { faGithub } from '@fortawesome/free-brands-svg-icons'
computed: {
fas () {
return fas
},
faGithub () {
return faGithub
}
},
and more.....
//nuxt.config.js
modules: [
[
'bootstrap-vue/nuxt', { css: true },
['nuxt-fontawesome', {
component: 'fa',
imports: [
//import whole set
{
set: '@fortawesome/free-solid-svg-icons',
icons: ['fas']
},
]
}]
],
],
fontawesome: {
component: 'fa',
imports: [
{
set: '@fortawesome/free-solid-svg-icons',
icons: ['fas']
},
],
},
Please let me ask for your help. I have spent long enough time on this issue already. Thank you in advance!
javascript nuxt
I'm trying to use font awesome 5 in my Nuxt project following the official guide below.
https://www.npmjs.com/package/nuxt-fontawesome
However, I'm getting a strange error and can't display what I want.
[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.
Here is how my code looks like:
//index.vue
<template>
<fa :icon="fas.faAddressBook" />
<fa :icon="faGithub" />
</template>
<script>
import { fas } from '@fortawesome/free-solid-svg-icons'
import { faGithub } from '@fortawesome/free-brands-svg-icons'
computed: {
fas () {
return fas
},
faGithub () {
return faGithub
}
},
and more.....
//nuxt.config.js
modules: [
[
'bootstrap-vue/nuxt', { css: true },
['nuxt-fontawesome', {
component: 'fa',
imports: [
//import whole set
{
set: '@fortawesome/free-solid-svg-icons',
icons: ['fas']
},
]
}]
],
],
fontawesome: {
component: 'fa',
imports: [
{
set: '@fortawesome/free-solid-svg-icons',
icons: ['fas']
},
],
},
Please let me ask for your help. I have spent long enough time on this issue already. Thank you in advance!
javascript nuxt
javascript nuxt
asked Nov 23 at 9:41
Masa
2014
2014
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Ok, I had a similar issue and found that the vue-fontawesome plugin worked although the nuxt-fontawesome one didn't. So, my steps:
npm install --save @fortawesome/vue-fontawesome @fortawesome/fontawesome-svg-core @fortawesome/free-solid-svg-icons
create a fontawesome.js file in plugins folder and put this in it:
import Vue from 'vue'
import { library, config } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { fas } from '@fortawesome/free-solid-svg-icons'
import { fab } from '@fortawesome/free-brands-svg-icons'
// This is important, we are going to let Nuxt.js worry about the CSS
config.autoAddCss = false
// You can add your icons directly in this plugin. See other examples for how you
// can add other styles or just individual icons.
library.add(fas)
library.add(fab)
// Register the component globally
Vue.component('font-awesome-icon', FontAwesomeIcon)
then in nuxt.config.js
css: [
'@fortawesome/fontawesome-svg-core/styles.css'
],
/*
** Plugins to load before mounting the App
*/
plugins: [
'~/plugins/fontawesome.js',
],
and then to use in any page:
<font-awesome-icon icon="['fab', 'facebook']" style="font-size: 22px"/>
That's pretty much all here
Thank you for your answer! Just after I posted this question, I found that workaround. But it is not how the official page explained so I wanted to find a straightforward way but it seems I need to use plugin anyway. Thank you for your answer very much again!
– Masa
Nov 23 at 11:46
No worries. If you're happy with the answer please mark it as correct.
– Andrew1325
Nov 23 at 20:17
Done. By the way, <font-awesome-icon icon="['fab', 'facebook']" style="font-size: 22px"/> this didnt work. Instead, <font-awesome-icon :icon="{ prefix: 'fab', iconName: 'facebook' }" style="color: #4267B2; font-size: 72px;"/> it needs to be like this. Just for the sake of ppl who see this page.
– Masa
Nov 23 at 23:26
Yeah I copied mine but I was using a v-for with an array of icons and was binding them so I had the:icon=
in it but thought it would be justicon=
if not dynamic. Guess not. Anyway, glad you got it working. Cheers.
– Andrew1325
Nov 24 at 0:10
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444093%2fgetting-error-when-trying-to-use-nuxt-font-awesome-5-although-i-followed-the-off%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Ok, I had a similar issue and found that the vue-fontawesome plugin worked although the nuxt-fontawesome one didn't. So, my steps:
npm install --save @fortawesome/vue-fontawesome @fortawesome/fontawesome-svg-core @fortawesome/free-solid-svg-icons
create a fontawesome.js file in plugins folder and put this in it:
import Vue from 'vue'
import { library, config } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { fas } from '@fortawesome/free-solid-svg-icons'
import { fab } from '@fortawesome/free-brands-svg-icons'
// This is important, we are going to let Nuxt.js worry about the CSS
config.autoAddCss = false
// You can add your icons directly in this plugin. See other examples for how you
// can add other styles or just individual icons.
library.add(fas)
library.add(fab)
// Register the component globally
Vue.component('font-awesome-icon', FontAwesomeIcon)
then in nuxt.config.js
css: [
'@fortawesome/fontawesome-svg-core/styles.css'
],
/*
** Plugins to load before mounting the App
*/
plugins: [
'~/plugins/fontawesome.js',
],
and then to use in any page:
<font-awesome-icon icon="['fab', 'facebook']" style="font-size: 22px"/>
That's pretty much all here
Thank you for your answer! Just after I posted this question, I found that workaround. But it is not how the official page explained so I wanted to find a straightforward way but it seems I need to use plugin anyway. Thank you for your answer very much again!
– Masa
Nov 23 at 11:46
No worries. If you're happy with the answer please mark it as correct.
– Andrew1325
Nov 23 at 20:17
Done. By the way, <font-awesome-icon icon="['fab', 'facebook']" style="font-size: 22px"/> this didnt work. Instead, <font-awesome-icon :icon="{ prefix: 'fab', iconName: 'facebook' }" style="color: #4267B2; font-size: 72px;"/> it needs to be like this. Just for the sake of ppl who see this page.
– Masa
Nov 23 at 23:26
Yeah I copied mine but I was using a v-for with an array of icons and was binding them so I had the:icon=
in it but thought it would be justicon=
if not dynamic. Guess not. Anyway, glad you got it working. Cheers.
– Andrew1325
Nov 24 at 0:10
add a comment |
Ok, I had a similar issue and found that the vue-fontawesome plugin worked although the nuxt-fontawesome one didn't. So, my steps:
npm install --save @fortawesome/vue-fontawesome @fortawesome/fontawesome-svg-core @fortawesome/free-solid-svg-icons
create a fontawesome.js file in plugins folder and put this in it:
import Vue from 'vue'
import { library, config } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { fas } from '@fortawesome/free-solid-svg-icons'
import { fab } from '@fortawesome/free-brands-svg-icons'
// This is important, we are going to let Nuxt.js worry about the CSS
config.autoAddCss = false
// You can add your icons directly in this plugin. See other examples for how you
// can add other styles or just individual icons.
library.add(fas)
library.add(fab)
// Register the component globally
Vue.component('font-awesome-icon', FontAwesomeIcon)
then in nuxt.config.js
css: [
'@fortawesome/fontawesome-svg-core/styles.css'
],
/*
** Plugins to load before mounting the App
*/
plugins: [
'~/plugins/fontawesome.js',
],
and then to use in any page:
<font-awesome-icon icon="['fab', 'facebook']" style="font-size: 22px"/>
That's pretty much all here
Thank you for your answer! Just after I posted this question, I found that workaround. But it is not how the official page explained so I wanted to find a straightforward way but it seems I need to use plugin anyway. Thank you for your answer very much again!
– Masa
Nov 23 at 11:46
No worries. If you're happy with the answer please mark it as correct.
– Andrew1325
Nov 23 at 20:17
Done. By the way, <font-awesome-icon icon="['fab', 'facebook']" style="font-size: 22px"/> this didnt work. Instead, <font-awesome-icon :icon="{ prefix: 'fab', iconName: 'facebook' }" style="color: #4267B2; font-size: 72px;"/> it needs to be like this. Just for the sake of ppl who see this page.
– Masa
Nov 23 at 23:26
Yeah I copied mine but I was using a v-for with an array of icons and was binding them so I had the:icon=
in it but thought it would be justicon=
if not dynamic. Guess not. Anyway, glad you got it working. Cheers.
– Andrew1325
Nov 24 at 0:10
add a comment |
Ok, I had a similar issue and found that the vue-fontawesome plugin worked although the nuxt-fontawesome one didn't. So, my steps:
npm install --save @fortawesome/vue-fontawesome @fortawesome/fontawesome-svg-core @fortawesome/free-solid-svg-icons
create a fontawesome.js file in plugins folder and put this in it:
import Vue from 'vue'
import { library, config } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { fas } from '@fortawesome/free-solid-svg-icons'
import { fab } from '@fortawesome/free-brands-svg-icons'
// This is important, we are going to let Nuxt.js worry about the CSS
config.autoAddCss = false
// You can add your icons directly in this plugin. See other examples for how you
// can add other styles or just individual icons.
library.add(fas)
library.add(fab)
// Register the component globally
Vue.component('font-awesome-icon', FontAwesomeIcon)
then in nuxt.config.js
css: [
'@fortawesome/fontawesome-svg-core/styles.css'
],
/*
** Plugins to load before mounting the App
*/
plugins: [
'~/plugins/fontawesome.js',
],
and then to use in any page:
<font-awesome-icon icon="['fab', 'facebook']" style="font-size: 22px"/>
That's pretty much all here
Ok, I had a similar issue and found that the vue-fontawesome plugin worked although the nuxt-fontawesome one didn't. So, my steps:
npm install --save @fortawesome/vue-fontawesome @fortawesome/fontawesome-svg-core @fortawesome/free-solid-svg-icons
create a fontawesome.js file in plugins folder and put this in it:
import Vue from 'vue'
import { library, config } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { fas } from '@fortawesome/free-solid-svg-icons'
import { fab } from '@fortawesome/free-brands-svg-icons'
// This is important, we are going to let Nuxt.js worry about the CSS
config.autoAddCss = false
// You can add your icons directly in this plugin. See other examples for how you
// can add other styles or just individual icons.
library.add(fas)
library.add(fab)
// Register the component globally
Vue.component('font-awesome-icon', FontAwesomeIcon)
then in nuxt.config.js
css: [
'@fortawesome/fontawesome-svg-core/styles.css'
],
/*
** Plugins to load before mounting the App
*/
plugins: [
'~/plugins/fontawesome.js',
],
and then to use in any page:
<font-awesome-icon icon="['fab', 'facebook']" style="font-size: 22px"/>
That's pretty much all here
answered Nov 23 at 10:58
Andrew1325
33828
33828
Thank you for your answer! Just after I posted this question, I found that workaround. But it is not how the official page explained so I wanted to find a straightforward way but it seems I need to use plugin anyway. Thank you for your answer very much again!
– Masa
Nov 23 at 11:46
No worries. If you're happy with the answer please mark it as correct.
– Andrew1325
Nov 23 at 20:17
Done. By the way, <font-awesome-icon icon="['fab', 'facebook']" style="font-size: 22px"/> this didnt work. Instead, <font-awesome-icon :icon="{ prefix: 'fab', iconName: 'facebook' }" style="color: #4267B2; font-size: 72px;"/> it needs to be like this. Just for the sake of ppl who see this page.
– Masa
Nov 23 at 23:26
Yeah I copied mine but I was using a v-for with an array of icons and was binding them so I had the:icon=
in it but thought it would be justicon=
if not dynamic. Guess not. Anyway, glad you got it working. Cheers.
– Andrew1325
Nov 24 at 0:10
add a comment |
Thank you for your answer! Just after I posted this question, I found that workaround. But it is not how the official page explained so I wanted to find a straightforward way but it seems I need to use plugin anyway. Thank you for your answer very much again!
– Masa
Nov 23 at 11:46
No worries. If you're happy with the answer please mark it as correct.
– Andrew1325
Nov 23 at 20:17
Done. By the way, <font-awesome-icon icon="['fab', 'facebook']" style="font-size: 22px"/> this didnt work. Instead, <font-awesome-icon :icon="{ prefix: 'fab', iconName: 'facebook' }" style="color: #4267B2; font-size: 72px;"/> it needs to be like this. Just for the sake of ppl who see this page.
– Masa
Nov 23 at 23:26
Yeah I copied mine but I was using a v-for with an array of icons and was binding them so I had the:icon=
in it but thought it would be justicon=
if not dynamic. Guess not. Anyway, glad you got it working. Cheers.
– Andrew1325
Nov 24 at 0:10
Thank you for your answer! Just after I posted this question, I found that workaround. But it is not how the official page explained so I wanted to find a straightforward way but it seems I need to use plugin anyway. Thank you for your answer very much again!
– Masa
Nov 23 at 11:46
Thank you for your answer! Just after I posted this question, I found that workaround. But it is not how the official page explained so I wanted to find a straightforward way but it seems I need to use plugin anyway. Thank you for your answer very much again!
– Masa
Nov 23 at 11:46
No worries. If you're happy with the answer please mark it as correct.
– Andrew1325
Nov 23 at 20:17
No worries. If you're happy with the answer please mark it as correct.
– Andrew1325
Nov 23 at 20:17
Done. By the way, <font-awesome-icon icon="['fab', 'facebook']" style="font-size: 22px"/> this didnt work. Instead, <font-awesome-icon :icon="{ prefix: 'fab', iconName: 'facebook' }" style="color: #4267B2; font-size: 72px;"/> it needs to be like this. Just for the sake of ppl who see this page.
– Masa
Nov 23 at 23:26
Done. By the way, <font-awesome-icon icon="['fab', 'facebook']" style="font-size: 22px"/> this didnt work. Instead, <font-awesome-icon :icon="{ prefix: 'fab', iconName: 'facebook' }" style="color: #4267B2; font-size: 72px;"/> it needs to be like this. Just for the sake of ppl who see this page.
– Masa
Nov 23 at 23:26
Yeah I copied mine but I was using a v-for with an array of icons and was binding them so I had the
:icon=
in it but thought it would be just icon=
if not dynamic. Guess not. Anyway, glad you got it working. Cheers.– Andrew1325
Nov 24 at 0:10
Yeah I copied mine but I was using a v-for with an array of icons and was binding them so I had the
:icon=
in it but thought it would be just icon=
if not dynamic. Guess not. Anyway, glad you got it working. Cheers.– Andrew1325
Nov 24 at 0:10
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444093%2fgetting-error-when-trying-to-use-nuxt-font-awesome-5-although-i-followed-the-off%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown