'Javascript modules don't work on github pages
I build a project with a local server (using live server VS extension), who works fine.
In this project, I'm using javascript modules, so in index.html, I have :
<script src="js/index.js" type="module"></script>
And in index.js :
import {} from "/js/home.js";
import {} from "/js/filter.js";
import {} from "/js/scroll.js";
The issue come when I try to display the website using github pages. JS files seems not found and browser console return :
home.js:1 Failed to load resource: the server responded with a status of 404 () filter.js:1 Failed to load resource: the server responded with a status of 404 ()
I tried to change paths with no success, and I have no idea why all works good locally but not with github pages
Solution 1:[1]
Maybe dot in path helps you
import {} from "./js/home.js";
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | DI S |