Next.js Discord

Discord Forum

DB connecting error - Learn nextjs chapter 6

Answered
Cuban Crocodile posted this in #help-forum
Open in Discord
Cuban CrocodileOP
I just deployed github repository 'nextjs-dashboard',
And I generated postgres DB. There is no errors at this step.
After then, I added "seed": "node -r dotenv/config ./scripts/seed.js" in 'package.json'
and then, I typed 'npm run seed' in my terminal, at this step errors are occured..

errors are as below :
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 (C:\Users\blacP\Documents\Next JS\nextjs-dashboard\node_modules@vercel\postgres\dist\chunk-PKSWROYW.cjs:158:11)
...

I checked POSTGRES_URL through console.log() which is undefined.

what's wrong with this? I think there is no problem in 'seed.js'
please help me out.
Answered by Ray
set the POSTGRES_URL variable in .env file
View full answer

6 Replies

set the POSTGRES_URL variable in .env file
Answer
at the root directory of the project
@Ray at the root directory of the project
Cuban CrocodileOP
thanks Ray, It's really helpful
Albacore
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/shashankrustagi/Desktop/nextjs-dashboard/node_modules/@vercel/postgres/dist/chunk-PKSWROYW.cjs:158:11)
at Object.get (/Users/shashankrustagi/Desktop/nextjs-dashboard/node_modules/@vercel/postgres/dist/chunk-PKSWROYW.cjs:201:16)
at main (/Users/shashankrustagi/Desktop/nextjs-dashboard/scripts/seed.js:164:27)
at Object.<anonymous> (/Users/shashankrustagi/Desktop/nextjs-dashboard/scripts/seed.js:174:1)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49 {
what to change in this?
POSTGRES_URL="postgres://default:7Aklo0uVbPXE@ep-throbbing-bird-a4lgf74t-pooler.us-east-1.postgres.vercel-storage.com:5432/verceldb"
POSTGRES_PRISMA_URL="postgres://default:7Aklo0uVbPXE@ep-throbbing-bird-a4lgf74t-pooler.us-east-1.postgres.vercel-storage.com:5432/verceldb?pgbouncer=true&connect_timeout=15"
POSTGRES_URL_NON_POOLING="postgres://default:7Aklo0uVbPXE@ep-throbbing-bird-a4lgf74t.us-east-1.postgres.vercel-storage.com:5432/verceldb"
POSTGRES_USER="default"
POSTGRES_HOST="ep-throbbing-bird-a4lgf74t-pooler.us-east-1.postgres.vercel-storage.com"
POSTGRES_PASSWORD="7Aklo0uVbPXE"
POSTGRES_DATABASE="verceldb"
Albacore
this is the error i am getting please help