prisma: Get error "atob is not defined"
Bug description
I try to run my server with prisma and in console I got the errors with one issue:
ReferenceError: atob is not defined
at new zt (C:\Users\olish\Desktop\horizon-rp\packages\node_modules\@prisma\client\runtime\library.js:115:8442)
at Sl (C:\Users\olish\Desktop\horizon-rp\packages\node_modules\@prisma\client\runtime\library.js:117:2032)
at new t (C:\Users\olish\Desktop\horizon-rp\packages\node_modules\@prisma\client\runtime\library.js:130:4621)
at Object.<anonymous> (C:\Users\olish\Desktop\horizon-rp\packages\db\index.js:9:14)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:782:14)
at Module.require (internal/modules/cjs/loader.js:965:19)
at require (internal/modules/cjs/helpers.js:88:18)
How to reproduce
I cant say how to reprocude this correctly
Expected behavior
No response
Prisma information
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = "mysql://root:@localhost:3306/rage-mp"
// url = env("DATABASE_URL")
}
enum Sex {
male
female
}
model User {
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
serialKey String
ip String
socialClub String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
characters Character[]
}
model Character {
id Int @id @default(autoincrement())
userId Int
user User @relation(fields: [userId], references: [id])
firstName String
lastName String
dob String
sex Sex
headProps Json
faceProps Json
regTopClothes Int
regLegsClothes Int
regShoesClothes Int
x Int @default(0)
y Int @default(0)
z Int @default(0)
h Int @default(0)
cash Int @default(0)
bank Int @default(0)
health Int @default(100)
satiety Int @default(100)
thirst Int @default(100)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
vehicles Vehicle[]
}
model Vehicle {
id Int @id @default(autoincrement())
ownerId Int
owner Character @relation(fields: [ownerId], references: [id])
modelName String @unique
plate String @unique
color1 Int
color2 Int
x Int
y Int
z Int
h Int
fuel Int @default(0)
mileage Int @default(0)
}
import { PrismaClient } from "@prisma/client";
// declare global {
// var prisma: PrismaClient | undefined;
// }
// export const db = globalThis.prisma || new PrismaClient();
export const db = new PrismaClient();
// globalThis.prisma = db;
If uncomment code, issue doest fix.
Environment & setup
- OS: Widnows 11
- Database: MySQL, Postges
- Node.js version: I tried with v20, v18, v16
Prisma Version
Tried use v.5.5.2, and the latest one.
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Reactions: 1
- Comments: 27 (15 by maintainers)
You’re right, I’ll recheck the requirements on my codebase and use a compatible version. Thanks for the help
Confirmed the problem is with jest 👍
@Alynva
atob
is supported in Node.js since version 16.0.0, and oldest version of Node.js that Prisma currently supports is 16.13.0, as per https://www.prisma.io/docs/orm/reference/system-requirements#software-requirements. There are probably other things that would or could break if you tried running Prisma on an unsupported older Node.js version, even if we didn’t useatob
/btoa
.Came here to say I got the same issue. Using Prisma
5.8.1
on Node 16.Edit: this only pops up when using Jest. Running the app regularly works.