question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Quickstart isn't working (no explanation of how to add DATABASE_URL to env)

See original GitHub issue

Bug description

I’m following the Quickstart example on the official site and get an error after running npm run dev


> script@ dev /prisma
> ts-node ./script.ts

(node:190106) UnhandledPromiseRejectionWarning: Error: 
Invalid `prisma.user.findMany()` invocation in
/prisma/script.ts:7:40

   4 
   5 // A `main` function so that you can use async/await
   6 async function main() {
→  7     const allUsers = await prisma.user.findMany(
  error: Environment variable not found: **DATABASE_URL**.
  -->  schema.prisma:3
   | 
 2 |   provider = "sqlite"
 3 |   url      = env("DATABASE_URL")
   | 

Validation Error Count: 1
    at CB (/prisma/node_modules/@prisma/client/runtime/index.js:38681:17)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:190106) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:190106) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

How to reproduce

  1. curl -L https://pris.ly/quickstart | tar -xz --strip=2 quickstart-master/typescript/starter
  2. cd starter && npm install
  3. Write a query and view the results
  4. npm run dev

Expected behavior

A working example that returns all the users query result with explanation of how to add DATABASE_URL to env.

Prisma information

datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

model Post {
  id        Int     @id @default(autoincrement())
  title     String
  content   String?
  published Boolean @default(false)
  author    User?   @relation(fields: [authorId], references: [id])
  authorId  Int?
}

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
  posts Post[]
}

Environment & setup

  • OS: Linux Mint
  • Database: SQLite
  • Node.js version: v14.17.5

Prisma Version

3.5.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ezalivadnyicommented, Nov 24, 2021

I downloaded the quickstarter archive again and I see .env file now. The problem became because I moved files when “Show Hidden Files” (Ctrl+H) was disabled so .env file wasn’t moved and missed. @janpio Thanks!

1reaction
robjinmancommented, Jan 8, 2022

My problem was I made a directory for the starter project, and then tried to move the files up a level with mv, which didn’t copy the hidden .env file. Doh!

mkdir prisma
cd prisma
curl -L https://pris.ly/quickstart | tar -xz --strip=2 quickstart-main/typescript/starter
mv ./starter/* ./
rm -r ./starter
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Use Environment Variables in App Platform
Next to the App-Level Environment Variables heading, click the Edit link. Encrypt Environment Variables. Click the Encrypt checkbox next to any variable to ......
Read more >
Connect your database | node-postgres
Connect your database. To connect your database, you need to set the url field of the datasource block in your Prisma schema to...
Read more >
Configuration Options
Environment variables are used for all configuration within a Directus project. These variables can be defined in a number of ways, ...
Read more >
Quickstart | Plaid Docs
Introduction. Let's test out running Plaid locally by cloning the Quickstart app. You'll need API keys, which you can receive by signing up...
Read more >
Quickstart: Query data in the Azure Data Explorer web UI
In this quickstart, you learn how to query and share data in the Azure ... In the Add Cluster dialog box, enter your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found