Error: Generator at prisma-json-schema-generator could not start
misha-erm opened this issue · 3 comments
Hi,
Was going to try your generator but faced this error:
Here is my schema.prisma:
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
// needed only when using heroku
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
generator jsonSchema {
provider = "prisma-json-schema-generator"
}
model Car {
id Int @id @default(autoincrement())
manufacturer String
model String
bodyType String
engineType String
transmission String
year Int
generation String
vin String
odometer Json
}
Versions I'm using:
"prisma": "2.17.0",
"prisma-json-schema-generator": "1.2.1"
Any ideas why this is happening?
Thanks in advance for any tips 👍🏻
@MikeYermolayev I will take a look! :)
@MikeYermolayev The issue is connected with the way you are calling prisma
.
Currently, you call prisma directly like this:
$ ./node_modules/.bin/prisma generate
1. Solution
Instead, if you are using yarn, just call prisma like this:
$ yarn prisma generate
This will call prisma the node
way, which will also respect the bin
folder within the node_modules
. Actually, this is very important:
"Within the bin folder, the binaries (executables) from your node modules are located. Executables are linked into {prefix}/bin on Unix, or directly into {prefix} on Windows. When in local mode, executables are linked into ./node_modules/.bin so that they can be made available to scripts run through npm. (For example, so that a test runner will be in the path when you run npm test.)"
When you directly try to run prisma without yarn or npm, the bin folder is not made available to prisma. Therefore prisma-json-schema-generator
also cannot be found.
If you don't use yarn, but npm, just place a generate command in the scripts section of your package json and run npm run generate
:
...
scripts: {
...
generate: "prisma generate"
...
}
...
2. Solution
If you are not able to change the way prisma is called, then change the setup for the prisma-json-schema-generator from:
generator jsonSchema {
provider = "prisma-json-schema-generator"
}
to:
generator jsonSchema {
provider = "node node_modules/prisma-json-schema-generator"
}
Hopefully, I could help you! :)
Thanks, makes sense👍🏻
Will try the provided advices and reopen if they won't help