next-learn
next-learn copied to clipboard
Missing connection string
I'm running into a problem after creating a vercel postgres db and connecting it to my project. I changed .env.example into .env and copy pasted the .env.local secrets. I also ran the "vercel env pull .env.development.local" and "npm install @vercel/postgres" commands as per vercels instructions. Then I run into the following problem of seeding the database with the "npm run seed" command:
npm run seed
seed node -r dotenv/config ./nextjs-dashboard/scripts/seed.js
An error occurred while attempting to seed the database: VercelPostgresError: VercelPostgresError - 'missing_connection_string': You did not supply a 'connectionString' and no 'POSTGRES_URL' env var was found.
at createPool (/Users/andor/Desktop/next_course_app/nextjs-dashboard/node_modules/@vercel/postgres/dist/chunk-PKSWROYW.cjs:158:11)
at Object.get (/Users/andor/Desktop/next_course_app/nextjs-dashboard/node_modules/@vercel/postgres/dist/chunk-PKSWROYW.cjs:201:16)
at main (/Users/andor/Desktop/next_course_app/nextjs-dashboard/scripts/seed.js:164:27)
at Object.
Can anyone help please? I would like to proceed with the course, but I'm stuck at this part.
Same problem as you. I found a solution in issue#484.
Thnx @sugarboo. It worked for me too. So the solution is to not use .env.example, but after having run "vercel env pull .env.development.local" change the .env.development.local file name to .env and then run "mpn run seed". Could hardly believe it when I finally saw the script running :)
Can the course material be adjusted to prevent others having these kind of issues?
Changing the name worked for me too! Had error about connection string missing when trying to seed. Mine had file name .env.example which I changed to .env
oh you can point to the config
"seed": "node -r dotenv/config ./scripts/seed.js dotenv_config_path=.env.development.local"
maybe you get the env not in the server component,but in the client component.
We're improving the seed process here so you can hit a URL in the browser: https://github.com/vercel/next-learn/pull/764