Font awesome as npm package any suggestion ?

Posted 7 months ago by gidaban79

Hello guys,

First Happy new Year :)

next :P

i have problem with import of font awesome as npm package;

import fontawesome from '@fortawesome/fontawesome-free';
import faCaretUp from '@fortawesome/free-solid-svg-icons/faCaretUp';
import faCaretDown from '@fortawesome/free-solid-svg-icons/faCaretDown';
import faStar from '@fortawesome/free-solid-svg-icons/faStar';
import faCheck from '@fortawesome/free-solid-svg-icons/faCheck';

fontawesome.library.add(faCaretUp,faCaretDown,faStar,faCheck);

and in console i get error

app.js:50294 Uncaught TypeError: Cannot read property 'add' of undefined
    at Module../resources/js/fontawesome.js (app.js:50294)
    at __webpack_require__ (app.js:20)
    at Object../resources/js/app.js (app.js:50117)
    at __webpack_require__ (app.js:20)
    at Object.0 (app.js:50316)
    at __webpack_require__ (app.js:20)
    at app.js:84
    at app.js:87

my package.json file

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch": "npm run development -- --watch",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
        "prod": "npm run production",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies": {
        "axios": "^0.18",
        "bootstrap": "^4.0.0",
        "cross-env": "^5.1",
        "jquery": "^3.2",
        "laravel-mix": "^4.0.7",
        "lodash": "^4.17.5",
        "popper.js": "^1.12",
        "resolve-url-loader": "^2.3.1",
        "sass": "^1.15.2",
        "sass-loader": "^7.1.0",
        "vue": "^2.5.17",
        "vue-template-compiler": "^2.5.21"
    },
    "dependencies": {
        "@fortawesome/fontawesome-free": "^5.6.3",
        "@fortawesome/free-solid-svg-icons": "^5.6.3"
    }
}

Please sign in or create an account to participate in this conversation.