Open lauriskuznecovs opened 4 years ago
@lauriskuznecovs I had the same problem. For me was a conflict between my @prisma/client dependency with the nexus-plugin-prisma dependency.
I was using in my project:
"@prisma/cli": "2.7.1"
"@prisma/client": "2.7.1"
and nexus-plugin-prisma was using:
"@prisma/cli": "2.7.0"
"@prisma/client": "2.7.0"
I updated my package.json to use 2.7.0 and got it working.
I see that you are using:
"@nexus/schema": "^0.15.0"
"nexus-plugin-prisma": "^0.18.2"
try to change your nexus-plugin-prisma to 0.19.0. I'm using this configuration and it's working.
@lauriskuznecovs I had the same problem. For me was a conflict between my @prisma/client dependency with the nexus-plugin-prisma dependency.
I was using in my project:
"@prisma/cli": "2.7.1" "@prisma/client": "2.7.1"
and nexus-plugin-prisma was using:
"@prisma/cli": "2.7.0" "@prisma/client": "2.7.0"
I updated my package.json to use 2.7.0 and got it working.
A possible solution for you
I see that you are using:
"@nexus/schema": "^0.15.0" "nexus-plugin-prisma": "^0.18.2"
try to change your nexus-plugin-prisma to 0.19.0. I'm using this configuration and it's working.
It did not helped. I got same error. Do you also have custom path for Prisma client?
If tried to debug file in which as an error:
/node_modules/nexus-plugin-prisma/dist/schema/dmmf/utils.js
exports.getPrismaClientDmmf = (packagePath) => { console.log(packagePath) // Returns "@prisma/client"
let dmmf = undefined;
try { console.log(require(packagePath).dmmf) // Returns "undefined"
dmmf = require(packagePath).dmmf;
}
catch (error) {
throw new Error(`Failed to import prisma client package at ${packagePath}. The following error occured while trying:
${error.stack}`);
}
if (!dmmf) {
throw new Error(`\
You most likely forgot to initialize the Prisma Client. Please run \`prisma generate\` and try to run it again.
If that does not solve your problem, please open an issue.`);
}
return dmmf;
};
@lauriskuznecovs I'm not using a custom path, just the normal import:
const { PrismaClient } = require('@prisma/client');
And the 'nexus-plugin-prisma'
is handling the '@prisma/client'
dependency for me. I don't have it in my package.json now.
As I mentioned above I am using custom path for client.
generator client {
provider = "prisma-client-js"
output = "./src/generated/client" <------------ here
binaryTargets = ["native", "linux-musl"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
///..... HERE are some models
That is described in Prisma docs, so there should not be a problem with custom path. https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/generating-prisma-client#specifying-a-custom-output-path
It shouldn't be a problem, but maybe nexus
is handling some prisma-client
config as well and it's conflicting.
In my file the generator is only setting the provider:
generator client {
provider = "prisma-client-js"
}
I'm using a custom location for storing the client. The client works but when I try to add it to nexus I get the same error.
Here's the versions I'm using:
"nexus-plugin-prisma": "^0.22.0" "@prisma/cli": "^2.9.0" "@prisma/client": "^2.9.0"
I suspect the error is somewhere in this code:
plugins: [
nexusSchemaPrisma()
],
typegenAutoConfig: {
contextType: 'Context.Context',
sources: [
{
source: require.resolve(
'../generated/prisma/saved_search/client'
),
alias: 'savedSearch'
},
{
source: require.resolve('../utils/types'),
alias: 'Context'
}
]
}
I can confirm this is still an issue with current latest versions.
"dependencies": {
"@prisma/client": "^2.13.1",
"apollo-server": "^2.17.0",
"dotenv-flow": "^3.2.0",
"graphql": "^15.4.0",
"nexus": "^1.0.0",
"nexus-plugin-prisma": "^0.27.0"
},
Hello @lauriskuznecovs,
This confused me also.
The client path should be set in the nexusPrisma config inputs.prismaClient
property.
https://nexusjs.org/docs/plugins/prisma/overview#configuration
And reference the type definition file in the sourceTypes.
export const PRISMA_PATH = path.resolve(__dirname, '../../generated/prisma2');
const nexusPrismaConfig: NexusPrismaOptions = {
inputs: { prismaClient: PRISMA_PATH }
};
export const schema = makeSchema({
types: types,
plugins: [nexusPrisma(nexusPrismaConfig)],
...
sourceTypes: {
modules: [
{
module: `${PRISMA_PATH}/index.d.ts`,
alias: 'prisma'
}
]
}
});
I'm also having this issue when trying to deploy my app to Google App Engine. Everything works locally, but the remote deploy fails (the GAE node install mechanism is a bit obscure tho). I'm not using any custom path.
I'm trying to use Prisma in a monorepo with 2 services. The prisma folder is a symlink to ../shared/prisma
.
INTRODUCTION
Everything was working in "nexus-plugin-prisma": "0.16.1" and problem appeared in all next versions.
ERROR
ENVIRONMENT
OS: 18.04.5 LTS (Bionic Beaver)" NPM: 6.14.8 NODE: v12.18.3
COMMENTS
I tried to debug that faulty file -
node_modules/nexus-plugin-prisma/dist/schema/dmmf/utils.js
by checking whats in packagePath. I think it holds wrong path to Prisma client. It is @prisma/client even I am using custom path, which is outside node_modules.REPRODUCTION
Commands to run:
package.json
prisma/prisma.schema
src/server.js
src/context.js
src/schema/index.js