0

I've been struggling with this for some time now and can't find the mistake I made. I want to use icons from FontAwesome in my express website. I installed fontawesome via npm as per their docs

$ npm install --save @fortawesome/fontawesome-free

I set up to serve static files in app.js:

app.use(express.static("public"));
app.use(express.static("node_modules/@fortawesome"));

and made reference in the boilerplate's head:

<link rel="stylesheet" href="/node_modules/@fortawesome/fontawesome-free/css/all.css">
<script src="/node_modules/@fortawesome/fontawesome-free/js/all.js"></script>

I'm getting 404 on all.js and for css:

MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled

where is or where are my mistakes? Thanks

paciekFly
  • 47
  • 7
  • You have to copy the needed files / fonts into the `public/..` folder, if you did not set up a build task to do this for you. Also see https://stackoverflow.com/questions/45581343/how-to-use-font-awesome-with-node-express-framework – Hans Spieß Apr 06 '21 at 00:06
  • 1
    Thanks for the reply. I have copied the whole fontawesome dir to public, changed paths in the head to look like this: but still I receive two errors. For js i have 404 and for css it "refused to apply style from 'http://localhost:3000/public/fontawesome/fontawesome-free/css/all.min.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled." – paciekFly Apr 06 '21 at 08:52

0 Answers0