when running type check on my project I get the following:
$ tsc
generated/typegen.ts:29:11 - error TS2304: Cannot find name 'NexusPrisma'.
29 crud: NexusPrisma<TypeName, 'crud'>
~~~~~~~~~~~
generated/typegen.ts:30:12 - error TS2304: Cannot find name 'NexusPrisma'.
30 model: NexusPrisma<TypeName, 'model'>
~~~~~~~~~~~
Should these be imported from somewhere? or am I missing a step?
Yesterday, I've updated to
"nexus": "^0.12.0-rc.4",
"nexus-prisma": "^0.5.2",
"prisma2": "2.0.0-preview016.2",
and now I am seeing the same issue.
I had to run the following to get this solved:
prisma2 generate
Run application so makeSchema(...) gets called again which takes care of updating the typegen.ts file
Wait for VSCode to pick up the changes ... this sometimes takes a few seconds (restart may help)
I'm experiencing the same issue.NexusPrisma type should be coming from node_modules/@types/nexus-prisma-typegen/index.d.ts. It is there:

But generated nexus.ts still can't find it.

Any suggestion, please?
@cypcz I ran into this because I had added in my tsconfig.json a definition for types: ["node"]. After removing the types key, it compiled fine. If you need your types defined there, there is likely a way to make this work too - but that's a pointer in the right direction at least.
@radicand thanks, but it didn't work for me. I temporarily fixed it by generating the types again to the folder, where nexus.ts lives.
I had to adjust nexusPrismaPlugin like this:
plugins: [
nexusPrismaPlugin({
// Fixes the Cannot find NexusPrisma issue
outputs: { typegen: __dirname + '/generated/index.ts' },
}),
],
Here was the solve for me:
Set "skipLibCheck": true in the compilerOptions property in the tsconfig.json file and run tsc again.
@radicand try to add "types": ["nexus-prisma-typegen"] in your tsconfig.json?
Closing this issue as there鈥檚 nothing really actionable for us. It is usually due to tsconfig issues. In the framework we solved this issue completely by managing everything including the tsconfig.
did anyone manage to get around this issue?
tried adding outputs: { typegen: path.join(process.cwd(), 'pages', 'api', 'index.ts') } but getting the same error
Can you provide more of your code? I currently don't have issues and I just followed the official getting started guide. Like already mentioned it may be because of an invalid tsconfig.
@mohe2015 here's a stripped-down repo that has the issue.
It's mainly following this prisma example, with a few changes:
t.crud....The app connects to a Postgres Heroku dataset (used solely for testing - that's why I included the credentials in the repo above).
If you clone the repo, npm i and npm run dev, you should get it up and running locally. It works perfectly fine locally - all mutations and queries work fine.
However, once deployed to Heroku, during build I get the Cannot find name 'NexusPrisma' error and deployment stops.
@bogdancss are you using heroku-prebuild task when deploying to heroku?
@jorgenskogas no, here's my scripts block:
```
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start -p $PORT",
"export": "next export",
"generate": "npm -s run generate:prisma && npm -s run generate:nexus",
"generate:prisma": "npx prisma generate",
"generate:nexus": "ts-node --transpile-only -P nexus.tsconfig.json pages/api",
"migrate": "npm -s run migrate:save && npm -s run migrate:up",
"migrate:save": "npx prisma migrate save --experimental",
"migrate:up": "npx prisma migrate up --experimental"
}
Can't test because it's really late but the following parts in tsconfig.json may help (honestly I have no idea):
{
"compilerOptions": {
"plugins": [
{
"name": "nexus/typescript-language-service"
}
],
"typeRoots": ["node_modules/@types", "types"],
},
"include": ["types.d.ts", "."]
}
Also I neither use next.js nor heroku so I can't help more.
@mohe2015 will give that a shot
@bogdancss this fixed it for me (if you test this locally, clean/delete your node_modules first)
import { makeSchema } from '@nexus/schema';
import { nexusSchemaPrisma } from 'nexus-plugin-prisma/schema';
import * as types from './types';
export const schema = makeSchema({
types,
- plugins: [nexusSchemaPrisma()],
+ plugins: [nexusSchemaPrisma({ outputs: { typegen: __dirname + '/generated/typegen-nexus-plugin-prisma.d.ts' } })],
outputs: {
schema: __dirname + '/generated/schema.graphql',
typegen: __dirname + '/generated/nexus.ts',
},
typegenAutoConfig: {
sources: [
{
source: '@prisma/client',
alias: 'client',
},
{
source: require.resolve('./context'),
alias: 'Context',
},
],
contextType: 'Context.Context',
},
});
@jorgenskogas doing that, it builds fine now. However, I am getting this error while trying to call the api:
Error: EROFS: read-only file system, mkdir '/generated'
@jorgenskogas ok, changed that to
outputs: { typegen: path.join(process.cwd(), 'pages', 'api', 'generated', 'typegen-nexus-plugin-prisma.d.ts') }
And it seems to be working fine now.
I ended up here after googling the same type error and I would like to mention that when NODE_ENV is set to production, type files are not generated.
In the case where you need to compile typescript on production environment, you need to specify shouldGenerateArtifacts option like below.
plugins: [
nexusSchemaPrisma({
// Generate typefiles on any occasions
shouldGenerateArtifacts : true,
outputs : {
typegen: __dirname + '/generated/typegen-nexus-plugin-prisma.d.ts'
}
})
],
{
"compilerOptions": {
// "types": ["node"], // breaks Nexus
"target": "ESNEXT",
"module": "commonjs",
Most helpful comment
@radicand thanks, but it didn't work for me. I temporarily fixed it by generating the types again to the folder, where
nexus.tslives.I had to adjust
nexusPrismaPluginlike this: