Search code examples
htmlnode.jsnode-modulesfirebase-hosting

why firebase didnt load node_modules files during host?


in my html, i'm using this to link the boostrap file

<link rel="stylesheet" type="text/css" href="/node_modules/bootstrap/dist/css/bootstrap.min.css"/>

I also tried this

@import url("/node_modules/bootstrap/dist/css/bootstrap.min.css");

I even try this for the javascript and its the same.

<script defer src="/node_modules/jquery/dist/jquery.min.js"/>

But both didnt even load at all? why?


Solution

  • I see two possible problems here:

    1. You are using paths with a leading slash, which means "from root". Your paths should either be ./node_modules/etc or node_modules/etc
    2. Firebase host does not run npm install and does not fetch depencencies. And I don't think it should, actually. You should either copy the ressources that you're going to use to a directory next to your html files (i.e. js or style) and load them with a script tag (i.e. href="./style/bootstrap.min.css or simply load them via any free CDN