Starting the Buliding Mobile App course.
Trying to work on local machine Ubuntu 24LTS- with VSCode
This is the code I have in the .env
DATABASE_URL="https://leads-trackerxxxx.firebasedatabase.app/"
(reducted)
this is my code in the index.js
// import { initializeApp } from "https://www.gstatic.com/firebasejs/10.8.1/firebase-app.js"
import { initializeApp } from "firebase"
// import { getDatabase } from "https://www.gstatic.com/firebasejs/10.8.1/firebase-database.js"
import { getDatabase } from "firebase"
const firebaseConfig = {
databaseURL: process.env.DATABASE_URL
}
const app = initializeApp(firebaseConfig)
const database = getDatabase(app)
console.log(firebaseConfig.DATABASE_URL)
let myLeads = []
.
.
.
this is the error I get from the terminal output tab in vscode with line 2 and 4 runnig
node:internal/modules/esm/resolve:857
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'firebase' imported from /home/sherab/Learning-Computing-Everything/Scrimba/copy-of-Mobile-App/Scrim-s069lst/index.js
at packageResolve (node:internal/modules/esm/resolve:857:9)
at moduleResolve (node:internal/modules/esm/resolve:926:18)
at defaultResolve (node:internal/modules/esm/resolve:1056:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:650:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:599:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:582:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:241:38)
at ModuleJob._link (node:internal/modules/esm/module_job:132:49) {
code: 'ERR_MODULE_NOT_FOUND'
}
Node.js v23.1.0
[Done] exited with code=1 in 0.034 seconds
this is the error code I get when line 2 and 4 are commeted out and line 1 and 3 are live:
[Running] node "/home/sherab/Learning-Computing-Everything/Scrimba/copy-of-Mobile-App/Scrim-s069lst/index.js"
node:internal/modules/esm/load:51
throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(url, supportedSchemes);
^
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file and data are supported by the default ESM loader. Received protocol 'https:'
at getSource (node:internal/modules/esm/load:51:11)
at defaultLoad (node:internal/modules/esm/load:114:40)
at ModuleLoader.load (node:internal/modules/esm/loader:666:12)
at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:479:43)
at #createModuleJob (node:internal/modules/esm/loader:503:36)
at #getJobFromResolveResult (node:internal/modules/esm/loader:274:34)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:242:41) {
code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}
Node.js v23.1.0
[Done] exited with code=1 in 0.034 seconds
and chrome devtools console returns:
index.js:7 Uncaught ReferenceError: process is not defined
at index.js:7:18
Any advice on how to add environment variable in vscode??