Deploy error with Astro

Hi, i am having problems to deploy my website and i am running out of ideas.

This is my astro.config.mjs:
"
export default defineConfig({
output: “server”,
adapter: cloudflare(),
integrations: [preact(), tailwind(), mdx()]
});
"

And this is my error:

20:19:08.018 23:19:08 [ERROR] [vite] [commonjs–resolver] Cannot bundle Node.js built-in path imported from node_modules/dotenv/lib/main.js. Consider disabling ssr.noExternal or remove the built-in dependency.
20:19:08.019 file: /opt/buildhome/repo/node_modules/dotenv/config.js
20:19:08.475 Cannot bundle Node.js built-in “path” imported from “node_modules/dotenv/lib/main.js”. Consider disabling ssr.noExternal or remove the built-in dependency.

Can someone guide me with this !
Thanks a lot!!!

You can’t use dotenv at runtime since it tries to read a file and there doesn’t exist a file on-edge.

Best to add env vars in wrangler.toml (docs). You may also be able to use dotenv at build time but not sure if Astro has a way for you to provide env vars.

1 Like