P
Postizβ€’2mo ago
Support

Ticket: "Production environment does not load .env configuration"

@ilearnbydoing Just created a ticket
Question: Production build error
Attempted: While starting app in production it does not read .env file.
Working On: Running in production
Take it from here @Mod πŸ”₯
17 Replies
Nevo David
Nevo Davidβ€’2mo ago
This error is popping up lately @ilearnbydoing, maybe something changed in the deployment, James will be available next weekm he can look into it πŸ™‚
Support
SupportOPβ€’2mo ago
@Mod πŸ”₯ please help @ilearnbydoing
xcons
xconsβ€’2mo ago
Heya, hmm @ilearnbydoing (nice username), how are you deploying?
ilearnbydoing
ilearnbydoingβ€’2mo ago
in development using npm
xcons
xconsβ€’2mo ago
Okay, and are you using "npm run dev"?
ilearnbydoing
ilearnbydoingβ€’2mo ago
working fine but not npm run start:prod npm run build
[email protected] build `npx nx run-many --target=build --projects=frontend,backend,workers,cron
βœ” nx run workers:build:production [local cache] βœ” nx run frontend:build:production [local cache] βœ” nx run backend:build:production [local cache] βœ” nx run cron:build:production [local cache] β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” NX Successfully ran target build for 4 projects (559ms) ` Nx read the output from the cache instead of running the command for 4 out of 4 tas
xcons
xconsβ€’2mo ago
Please use 3x ` when pasting code Okay. If dev is working fine, prod should run fine too Are you looking to write code for postiz by the way, or just use it?
ilearnbydoing
ilearnbydoingβ€’2mo ago
yes wanna write code. when i run npm run start:prod i am getting ----- [Nest] 2337258 - 10/20/2024, 12:29:10 PM ERROR [PrismaClientInitializationError: error: Environment variable not found: DATABASE_URL. --> schema.prisma:10 | 9 | provider = "postgresql" 10 | url = env("DATABASE_URL") | alothough i exported them manually then too start error
ilearnbydoing
ilearnbydoingβ€’2mo ago
exported them manually
No description
ilearnbydoing
ilearnbydoingβ€’2mo ago
then too does not start rm -rf dist npx nx reset npm run build npm run start:prod tried again and again docker build the one provided in production working fine
Nevo David
Nevo Davidβ€’2mo ago
Did you copy .env.example to .env?
ilearnbydoing
ilearnbydoingβ€’2mo ago
yes using node v20
Mirza
Mirzaβ€’2mo ago
Ohhh You need to add the JWT_SECRET=β€œβ€ And then npm run dev Make sure you have random string in jwt secret and it should be at least 12 characters Make sure you installed pg admin postgres and set {DATABASE_URL="postgresql://postiz-user:postiz-password@localhost:5432/postiz-db-local"} then npm run prisma-db-push The main issue is that you are using wrong password or username of your db
ilearnbydoing
ilearnbydoingβ€’2mo ago
everything fine in development npm run dev work fine but not not npm run start:prod
No description
No description
Nevo David
Nevo Davidβ€’2mo ago
@ilearnbydoing just a clarification, in production, are you trying to run the docker?
ilearnbydoing
ilearnbydoingβ€’2mo ago
Docker works fine production I am trying to setup dev environment for mono repo I followed the official developer guide it does not work while starting with npm run start:prod It does not read .env and when I export all .env variables then too its not starting up
xcons
xconsβ€’2mo ago
hey @ilearnbydoing did you ever solve this, do you still need help?
Want results from more Discord servers?
Add your server