-
Notifications
You must be signed in to change notification settings - Fork 2.4k
create-payload-app in existing Next.js project replaces .env and .env.example contents #10355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Screen.Recording.2025-01-15.at.4.02.49.PM.movHi @smoores-dev, I used the reproduction you provided and am unable to replicate this behavior. Could you send a screenshot? There might be something I am missing in your steps. |
Hi @JessChowdhury! It looks like you're running |
|
@smoores-dev thank you I see the issue now! |
### What? Using `create-payload-app` to initialize Payload in an existing Next.js app **that does not already have Payload installed** overwrites any existing data in the `.env` and `.env.example` files. The desired behavior is for Payload variables to get added with no client data lost. ### How? Updates `manageEnvFiles` to check for existing `.env / .env.example` file and appends or creates as necessary. Adds tests to `packages/create-payload-app/src/lib/create-project.spec.ts`. #### Fixes #10355
🚀 This is included in version v3.37.0 |
Describe the Bug
On the tin! I had a .env file with several variables in it; after running
npx create-payload-app
, the entire contents were replaced with:Link to the code that reproduces this issue
https://github.com/smoores-dev/payload-dotenv-clear-repro
Reproduction Steps
You can just see the issue by looking at the .env.example file between the two commits in that repo. To reproduce:
git checkout init
to check out the initial commit.env
file and put an environment variable in itnpx create-payload-app
(choose whatever options)Which area(s) are affected? (Select all that apply)
Not sure
Environment Info
The text was updated successfully, but these errors were encountered: