I get the following error message when I try to run a local node server with a very simple application (see coding below).
Loading module from “http://localhost:
I know that you're importing just the command, but I'll let you know my solution for this and see if you're interested. This error, for me, came from the import statement in your module. I was trying to import the entire file, with all functions and imports it had, while essentially using the same server and HTML.
my importing.js:
import * as Spotify from "./spotify-web-api.js";
window.basicAlert = function basicAlert() {
alert("this is a test to see if basicAlert runs properly");
}
console.log("Should print to console with no error on imports");
I don't know the logic behind the import * as
, but it worked to successfully import my file without throwing a MIME type error. As for the window.basicAlert =
, Javascript apparently doesn't like to give any file that imports it access to its functions or variables unless it's manually attached to the window. You don't have this error now, but after the file imports successfully it will tell you that a
isn't defined. While I have it attached to my function in importing.js, you'll need to put it in exporting.js like this:
const a = 'Constant a';
windows.a = a;
I didn't test that ^ but it makes sense to me. I hope this can help you out, or get closer, cause it solved my problem.