Bug description
prisma generate with custom output settings creates clients all with the same package name ("./prisma/client"). It should use a unique name, such as the output path as the package name.
This causes issues in some dependency management tools, such as jest-haste-map (used by [email protected]), preventing jest from running in projects with more than one client.
This is a typical error you may get as a result of this:
The name `.prisma/client` was looked up in the Haste module map. It cannot be resolved, because there exists several different files, or packages, that provide a module for that particular name and platform. The platform is generic (no extension). You must delete or exclude files until there remains only one of these:
* `<rootdir>/generated/database/client1/package.json` (package)
* `<rootdir>/generated/database/client2/package.json` (package)
How to reproduce
- Start with a project setup with
prisma init, providing enough information for prisma generate to run.
- Run
prisma generate
- Edit
generator client in schema file, so that it includes an output directive (output: "../generated/database/client")
- Re-run
prisma generate
- The file at
<rootdir>/generated/database/client/package.json is the same as <rootdir>/node_modules/.prisma/client/package.json, and reads as follows:
{
"name": ".prisma/client",
"main": "index.js",
"types": "index.d.ts"
}
Optional: run jest --clearCache to see the impact of this.
Expected behavior
The generated directory to have a package.json as follows (or similar):
{
"name": "generated/database/client",
"main": "index.js",
"types": "index.d.ts"
}
Mitigations
- Where the client is not required by dependency management tool: Adding the path for generated modules in any relevant exclusion path (e.g.
testModuleIgnorePatterns for jest).
- Otherwise: manually renaming the generated package.json name each time
prisma generate is called
Prisma information
generator client {
provider = "prisma-client-js"
output = "../generated/database/client"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
...etc
Environment & setup
I expect this issue arises in all environments. Here is mine:
- OS: Mac OS
- Database: MySQL
- Node.js version: v14.10.1
- Prisma version: 2.9.0
Bug description
prisma generatewith custom output settings creates clients all with the same package name ("./prisma/client"). It should use a unique name, such as the output path as the package name.This causes issues in some dependency management tools, such as jest-haste-map (used by [email protected]), preventing jest from running in projects with more than one client.
This is a typical error you may get as a result of this:
How to reproduce
prisma init, providing enough information forprisma generateto run.prisma generategenerator clientin schema file, so that it includes an output directive (output: "../generated/database/client")prisma generate<rootdir>/generated/database/client/package.jsonis the same as<rootdir>/node_modules/.prisma/client/package.json, and reads as follows:Optional: run
jest --clearCacheto see the impact of this.Expected behavior
The generated directory to have a package.json as follows (or similar):
Mitigations
testModuleIgnorePatternsfor jest).prisma generateis calledPrisma information
Environment & setup
I expect this issue arises in all environments. Here is mine: