I am trying to import a module to my JavaScript code, which should later run on a WordPress server.
Currently i wanted to test it on localhost, but it gives me an error like:
The Skript from "http://127.0.0.1:46513/js/main.js" was loaded, despite it's MIME-Typ ("text/html") is not valid in JavaScript
Which is strange because it is js code and not html.
My main.js looks like this:
const { Origin, Horoscope } = require('./circular-natal-horoscope-js/dist/index.js');
And index.html like this:
<html>
<head> Horoscope </head>
<body>
<script type="text/javascript" src="js/require.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html>
I also tried different import syntax:
import { Origin, Horoscope } from '/circular-natal-horoscope-js/dist/index.js';
Which gives me the same error.
The only thing which is working is, when i type in node main.js into console, then the Origin and Horoscope functions are beeing loaded.
How can i use this to be working in my js-files without using the console?