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 π₯
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
This error is popping up lately @ilearnbydoing,
maybe something changed in the deployment,
James will be available next weekm he can look into it π
@Mod π₯ please help @ilearnbydoing
Heya, hmm
@ilearnbydoing (nice username), how are you deploying?
in development using npm
Okay, and are you using "npm run dev"?
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
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?
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
exported them manually
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
Did you copy .env.example to .env?
yes
using node v20
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
everything fine in development
npm run dev
work fine
but not not npm run start:prod
@ilearnbydoing just a clarification, in production, are you trying to run the docker?
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
hey @ilearnbydoing did you ever solve this, do you still need help?