next-learn icon indicating copy to clipboard operation
next-learn copied to clipboard

Missing connection string

Open thenftdoctor opened this issue 1 year ago • 5 comments

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. (/Users/andor/Desktop/next_course_app/nextjs-dashboard/scripts/seed.js:174:1) at Module._compile (node:internal/modules/cjs/loader:1267:14) at Module._extensions..js (node:internal/modules/cjs/loader:1321:10) at Module.load (node:internal/modules/cjs/loader:1125:32) at Module._load (node:internal/modules/cjs/loader:965:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) at node:internal/main/run_main_module:23:47 { code: 'missing_connection_string' }

Can anyone help please? I would like to proceed with the course, but I'm stuck at this part.

thenftdoctor avatar Dec 12 '23 20:12 thenftdoctor

Same problem as you. I found a solution in issue#484.

sugarboo avatar Dec 13 '23 02:12 sugarboo

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?

thenftdoctor avatar Dec 13 '23 05:12 thenftdoctor

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

dipeshsgdl avatar Feb 02 '24 09:02 dipeshsgdl

oh you can point to the config "seed": "node -r dotenv/config ./scripts/seed.js dotenv_config_path=.env.development.local"

lpoulter1 avatar Feb 02 '24 22:02 lpoulter1

maybe you get the env not in the server component,but in the client component.

M-Anonymous avatar Mar 25 '24 09:03 M-Anonymous

We're improving the seed process here so you can hit a URL in the browser: https://github.com/vercel/next-learn/pull/764

leerob avatar Jun 23 '24 22:06 leerob