I am trying to use Firebase SDK on my Google App Script app.
The documentation says it needs installing npm install firebase
which is not possible via Google App Script.
So the following step would be:
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "***",
authDomain: "myapp.firebaseapp.com",
databaseURL: "https://myapp-default-rtdb.europe-west1.firebasedatabase.app",
projectId: "myappurl",
storageBucket: "myappurl.appspot.com",
messagingSenderId: "267227785525",
appId: "***",
measurementId: "G-K5CP51FRXR"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
But i get the error:
SyntaxError: Cannot use import statement outside a module linea:
It looks like i am not declaring it as a module. I have checked for tutorials and help but only find the how-to for Node.js, Google Script is not talked about.
Note: I have installed 'FirebaseApp' library.
Anyone knows how to do what i need? Is that even possible to use SDK v9 on GAS?