N
Neon2y ago
provincial-silver

Production builds can't read the .env variable

Hi guys I'm facing a problem where when i try to npm run build my sveltekit project it's complaining that :
Error: No database connection string was provided to `neon()`. Perhaps an environment variable has not been set?
Error: No database connection string was provided to `neon()`. Perhaps an environment variable has not been set?
when i run it on the dev mode it is working perfectly i'm also using drizzle
No description
11 Replies
xenial-black
xenial-black2y ago
How are you loading the environment variables from .env? You need to call dotenv.config() in your code, or add it as a flag to the node command per the docs https://www.npmjs.com/package/dotenv I’m guessing that your dev mode command loads dotenv, but the production mode command does not.
npm
dotenv
Loads environment variables from .env file. Latest version: 16.4.1, last published: 3 days ago. Start using dotenv in your project by running npm i dotenv. There are 39414 other projects in the npm registry using dotenv.
provincial-silver
provincial-silverOP2y ago
Hi this is solved. sveltekit has it's own method to importing the environment variable
xenial-black
xenial-black2y ago
Great! Glad you’re unblocked
provincial-silver
provincial-silverOP2y ago
thank you @ShinyPokemon
conscious-sapphire
conscious-sapphire2y ago
Hello everyone! I noticed there's no documentation available for integrating Drizzle, and I'm wondering if anyone can shed light on this. I want to ensure my installation is correct. While I see guides for Prisma and other tools, Drizzle seems to be missing. My current focus is on mastering Neon natively and deploying to Vercel. However, I prefer not to use Vercel's Postgres storage. Instead, I've opted to manage Neon and Drizzle ORM to replace Prisma. Although I've managed to make everything work so far, I still have some uncertainties. Is there a repository or a concise tutorial specifically covering the usage of Neon, Next.js, Drizzle, and TypeScript together?
afraid-scarlet
afraid-scarlet2y ago
Hi @Luc , that's on our list to add to the docs. In the meantime, please have a look at this blog post: https://neon.tech/blog/api-cf-drizzle-neon#add-drizzle-orm-to-your-project Let me know how you make out.
Neon
Build a serverless API using Cloudflare Workers, Drizzle ORM, and N...
In this guide, you will learn how to build and deploy a serverless API using Cloudflare Workers, Drizzle ORM, and Neon.
afraid-scarlet
afraid-scarlet2y ago
Drizzle ORM - next gen TypeScript ORM
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
conscious-sapphire
conscious-sapphire2y ago
Thank you for this prompt response. Will take a look and let you know for sure. Cheers! Working all nicely now! Thanks and cheers. Will read the rest of the docs for advance stuff. If you have any other info like this or repositories, please share. Thanks again!
afraid-scarlet
afraid-scarlet2y ago
We'll do that. Glad that helped!
xenial-black
xenial-black2y ago
@Luc I also have two example repositories using Neon and Drizzle. Check this link: https://github.com/evanshortiss?tab=repositories&q=driz&type=&language=&sort=
GitHub
evanshortiss - Repositories
DevRel at @neondatabase 🐘. evanshortiss has 378 repositories available. Follow their code on GitHub.
conscious-sapphire
conscious-sapphire2y ago
Awesome! I will indeed take a look at this. Thank you Evan!

Did you find this page helpful?