chen-rn / CUA

(deprecateed) create-universal-app(CUA) is an opinionated template for creating fullstack universal apps (Expo, Next, tRPC, Prisma, Clerk, Solito, Tamagui)
https://cua-demo.vercel.app
MIT License
1.02k stars 67 forks source link

.env not working in root #9

Closed gascenciom1998 closed 1 year ago

gascenciom1998 commented 1 year ago

I started from an existing nextjs web app, migrated everything to CUA (basically just putting my nextJS app insice apps/web). For some reason the environment variables are undefined, but it does work if I move .env inside apps/web. Still that feels wrong and I want to share the env variables across both apps but I think I may be missing some configurations somewhere.

jllewis11 commented 1 year ago

For the .env in the DB folder, I had to manually link it by stating in the main package.json

"prisma": { "schema": "./packages/db/prisma/schema.prisma },

Prisma env docs From here, the third option.

I'm not too sure if @chen-rn would like to add this to the main package.json, so the db's env can be utilized.

chen-rn commented 1 year ago

Hey!

So the env thing should've been fixed in one of the early commits, did you happen to have cloned before that? @jllewis11

@gascenciom1998 does your db package.json have this line?

It seems that my envs are working fine when I follow the instructions.

chen-rn commented 1 year ago

Also, I think the package.jsons overall can have some improvements as well. Use more turbo build stuff, less yarn stuff, etc!

chen-rn commented 1 year ago

It seems that without this line, you're able to use Prisma in dev but not in prod. I've added it to the root package json! Thanks for the tip Jerry @jllewis11