This is the error I'm getting on the website that I host:
Uncaught SyntaxError: Cannot use import statement outside a module
I've spent the last few hours scanning the internet and the stack with so many questions like this but none solved my issue.
JavaScipt Code:
import { initializeApp } from "firebase/app"; // The error is getting on this line already
import { getAnalytics } from "firebase/analytics";
import { getStorage } from "firebase/storage";
In the index.html
body:
<script src="js/get_firebase_data.js"></script>
I also tried putting type="module"
in the script but still no luck.
My package.json
file:
{
"dependencies": {
"firebase": "^9.17.1",
"jquery": "^3.6.3"
},
"type": "module",
"name": "sols",
"version": "1.0.0",
"main": "index.html",
"scripts": {
"build": "npm run bundle && npm run minify",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "DIF",
"license": "ISC",
"description": ""
}
Update:
Someone suggested that this answers my question: "Uncaught SyntaxError: Cannot use import statement outside a module" when importing ECMAScript 6, but it does not, I just tried all of the suggested answer in that question plus many other questions I found, but still no luck in finding a solution for me.
If you need me to provide any more information about my situation, please comment and I shall provide it for you shortly, thank you.