Complete error: Uncaught ReferenceError: module is not defined at vsop87Bearth.js:1
I`m trying to use some js files that I found from this(https://github.com/commenthol/astronomia) repository to calculate the rectangular coordinates of the sun. I'm new to js and servers so im not sure on how to use module.exports. There is a file called vsop87Bearth.js with some coordinates that modelates the earth and it looks like this:
module.exports = {
stuff: numbers,
name: "earth"
};
And I need to use the vsop87Bearth.js file with a function called position() to do what I need. This is the module Funcion_PSol.js where Im trying to calculate things:
import position from './astronomia-master/src/solarxyz.js'
import Planet from './astronomia-master/src/planetposition.js'
import * as earth from './astronomia-master/data/vsop87Bearth.js' //I'm not sure of THIS line
var tierra = new Planet(earth);
var pos = position(earth, 2448908.5)
Also, the error might be caused from the HTML file, this is it:
<!DOCTYPE html>
<html>
<head>
<script type="module" src="./astronomia-master/data/vsop87Bearth.js"></script>
<script type="module" src="Funcion_PSol.js"></script>
</head>
</html>
Note: I´m using browsersync to host my project and Im not using Node
Since you are using the esm syntax, you will need to update the export syntax to the following.
export = {
stuff: numbers,
name: "earth"
};