4

I'm trying to deploy a website using GitHub Pages. For some reason the JavaScript files will not load and I get the following error.

mywebsite.github.io/node_modules/three/examples/jsm/controls/OrbitControls.js” was blocked because of a disallowed MIME type (“text/html”)

For some reason it believes that the .js file is a html file.

I am using <base href="."> as the base href as this was found to be the issue here Disallowed MIME type (“text/html”) error - Angular Github pages

I am loading the js script like so <script type="module" src="main.js"></script>

Within main.js I am importing like so:

import './style.css';

import {OrbitControls} from '../node_modules/three/examples/jsm/controls/OrbitControls.js';
import * as THREE from '../node_modules/three/build/three.js';

I have tried various file paths such as /, ./, ../ and I am having no luck.

My folder structure is looking like this.

enter image description here

I've also tried adding an empty .nojekyll file as apparently this may prevent gh-pages from excluding node_modules, I've also added !node_modules to my .gitignore.

Any help would be appreciated.

DB1995
  • 91
  • 2

0 Answers0