I'm facing some issues trying to implement FontAwesome in my NuxtJS project, and for some unknown reasons, it's not working as expected.
Let's take a look at my package.json
:
{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview"
},
"devDependencies": {
"nuxt": "3.0.0-rc.6",
"sass": "^1.54.0",
"sass-loader": "^13.0.2"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.1.2",
"@fortawesome/free-regular-svg-icons": "^6.1.2",
"@fortawesome/free-brands-svg-icons": "^6.1.2",
"@fortawesome/free-solid-svg-icons": "^6.1.2",
"@fortawesome/vue-fontawesome": "^3.0.1",
"@nuxtjs/fontawesome": "^1.1.2"
}
}
Next, let's examine my nuxt.config.ts
:
import { defineNuxtConfig } from 'nuxt'
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
buildModules: ['@nuxtjs/fontawesome'],
fontawesome: {
icons: {
solid: ['faHome']
}
}
})
Now onto the content of pages/index.vue
:
<template>
<div>
Hello
</div>
</template>
Although I haven't used any icons in this example, when I try to run my app using npm run dev
, I encounter the following error:
ℹ Vite client warmed up in 440ms 12:52:57
ℹ Vite server warmed up in 113ms 12:52:57
...
[h3] [unhandled] H3Error: Cannot read properties of undefined (reading 'component')
at createError ...
This error is quite puzzling to me, especially since I couldn't find any similar cases online. As a newcomer to NuxtJS and Vue, this issue is giving me some trouble.
I've been following the documentation provided by @nuxtjs/fontawesome, and based on that, it seems like everything is set up correctly. Hopefully, this is just a minor oversight on my part.
Edit
In addition to the error, the text "Hello" on my page is being displayed as plain text within a black background, and it's not rendering properly.
{
"statusCode": 404,
"statusMessage": "Not Found",
"stack": []
}