I want to use the "lunarphase-js" api (I have installed it with "npm i lunarphase-js") but I get this error when I want to import it.
error: Cannot use import statement outside a module (at app.js:1:1)
app.js:
import { Moon } from "lunarphase-js";
const date = new Date();
const phase = Moon.lunarPhase(date);
console.log(phase);
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Lunar App</title>
<script src="app.js"></script>
<link rel="stylesheet" href="style.css" />
<script type="commonjs" src="node_modules/lunarphase-js/dist/cjs/lunarphase-js.js"></script>
</head>
<body></body>
</html>
package.json:
{
"dependencies": {
"lunarphase-js": "^1.0.10"
}
}