PazzeG
PazzeG

Reputation: 137

dotenv Error: Cannot find module at {Path}/main.jsx

I'm building a web-site, and using Firebase to store data. So, the private keys are on a .env file. I'm trying to import them in a firebase config file. I'm using import in order to use modules. And by following the guide in the dotenv doc, I ran 'node -r dotenv/config main.jsx' on my terminal. But I got an error, and I don't understand what to do. Thanks !

Folders' Architecture enter image description here

Firebase.js enter image description here

main.jsx enter image description here

Upvotes: 1

Views: 165

Answers (1)

Antoine Gagnon
Antoine Gagnon

Reputation: 982

It seems you are using Vite which already supports .env files.

It's exposed in the import.meta.env object. Try replacing process.env. for import.meta.env. in your code.

See the documentation here: https://vitejs.dev/guide/env-and-mode.html#env-files

Upvotes: 1

Related Questions