Quickstart isn't working (no explanation of how to add DATABASE_URL to env)
See original GitHub issueBug 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
- curl -L https://pris.ly/quickstart | tar -xz --strip=2 quickstart-master/typescript/starter
- cd starter && npm install
- Write a query and view the results
- 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:
- Created 2 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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!
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!