prisma-labs / graphql-framework-experiment

Code-First Type-Safe GraphQL Framework
https://nexusjs.org
MIT License
674 stars 66 forks source link

`nexus build` failing on Windows #1269

Open tafelnl opened 4 years ago

tafelnl commented 4 years ago
$ 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)

tafelnl commented 4 years ago

might be related to https://github.com/graphql-nexus/nexus/issues/1227

seed-of-apricot commented 4 years ago

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, '/');