graphql-framework-experiment
graphql-framework-experiment copied to clipboard
`nexus build` failing on Windows
$ npx nexus build
955 ● nexus:build get used plugins
● nexus:plugin:nexusPluginPrisma Running generators
● nexus:build starting reflection
● nexus:build building typescript program
● nexus:build compiling a production build
node_modules/@types/typegen-nexus-plugin-prisma/index.d.ts:2:25 - error TS2307: Cannot find module '.....prismaclient' or its corresponding type declarations.
2 import * as Prisma from '..\..\.prisma\client';
~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/typegen-nexus/index.d.ts:6:13 - error TS2300: Duplicate identifier 'Prisma'.
6 import * as Prisma from "../../.prisma/client/index"
~~~~~~
node_modules/@types/typegen-nexus/index.d.ts:11:13 - error TS2300: Duplicate identifier 'Prisma'.
11 import * as Prisma from "..\..\.prisma\client\index"
~~~~~~
node_modules/@types/typegen-nexus/index.d.ts:11:25 - error TS2307: Cannot find module '.....prismaclientindex' or its corresponding type declarations.
11 import * as Prisma from "..\..\.prisma\client\index"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: node_modules/@types/typegen-nexus-plugin-prisma/index.d.ts:2:25 - error TS2307: Cannot find module '.....prismaclient' or its corresponding type declarations.
2 import * as Prisma from '..\..\.prisma\client';
~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/typegen-nexus/index.d.ts:6:13 - error TS2300: Duplicate identifier 'Prisma'.
6 import * as Prisma from "../../.prisma/client/index"
~~~~~~
node_modules/@types/typegen-nexus/index.d.ts:11:13 - error TS2300: Duplicate identifier 'Prisma'.
11 import * as Prisma from "..\..\.prisma\client\index"
~~~~~~
node_modules/@types/typegen-nexus/index.d.ts:11:25 - error TS2307: Cannot find module '.....prismaclientindex' or its corresponding type declarations.
11 import * as Prisma from "..\..\.prisma\client\index"
I also have a Virtual Machine (Ubuntu) running. I ran the exact same command (nexus build), and it works just fine.
Tested on Windows with nexus version ^0.26.0-next.8 (not working)
Tested on Ubuntu with nexus version ^0.26.0-next.8 and ^0.25.0 (both working)
might be related to https://github.com/graphql-nexus/nexus/issues/1227
This is again the path resolution in Windows.
Workaround:
// node_modules/nexus-plugin-prisma/dist/schema/typegen/render.js
// line 40: add .replace(/\\/g, '/')
const prismaClientImportId = Path.isAbsolute(options.typegenPath) && Path.isAbsolute(options.prismaClientPath)
? Path.relative(Path.dirname(options.typegenPath), options.prismaClientPath).replace(/\\/g, '/')
: options.prismaClientPath;
// node_modules/nexus/dist/lib/nexus-schema-stateful/typegen.js
// line 84: add .replace(/\\/g, '/')
const relativeImportPath = (Path.isAbsolute(typegenImport.from)
? NexusSchema.core.relativePathTo(typegenImport.from, outputPath)
: typegenImport.from).replace(/(\.d)?\.ts/, '').replace(/\\/g, '/');