Prisma-client-js: Cannot find module '@generated/photon'

Created on 23 Jun 2019  Â·  16Comments  Â·  Source: prisma/prisma-client-js

when i use prisma2 init to generate a new project and run:

yarn run v1.17.0
$ ts-node prisma/seed.ts

/Users/a/Downloads/prisma2/node_modules/ts-node/src/index.ts:245
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
prisma/seed.ts:1:20 - error TS2307: Cannot find module '@generated/photon'.

1 import Photon from '@generated/photon'
bu0-needs-info kinbug

Most helpful comment

@ManAnRuck A change in preview-2 requires that you remove the output property from

generator nexus_prisma {
  provider = "nexus-prisma"
  output   = "node_modules/@generated/nexus-prisma"
}

See #143 for details.

All 16 comments

Have you tried prisma2 generate ?

1). Create a new migration

prisma2 lift save --name 'init'

2). Migrate your database up

prisma2 up

3). Generate Photon

prisma2 generate

Same issue for me but when running the graphql-auth example and npm start

This issue has been resolved in the latest CLI version 0.0.95, please install it using npm install -g prisma2 and try again.

Related issue: https://github.com/prisma/prisma2-cli/issues/6 (This is the correct repository for creating CLI related issues)

Closing. We can reopen if it's still an issue :-)

Still happening for me with [email protected]

Update: I've just noticed that this will happen when I add "target": "es6" to tsconfig.json, removed it and the issue goes away, not sure if this is a problem or not.

@lednhatkhanh : Can you please share your Prisms schema file? (project.prisma)

@divyenduz I have a simple model file just like this:

datasource db {
  provider = "sqlite"
  url      = "file:dev.db"
  default  = true
}

generator photon {
  provider = "photonjs"
}

generator nexus_prisma {
  provider = "nexus-prisma"
  output   = "node_modules/@generated/nexus-prisma"
}

model User {
  id          String       @default(cuid()) @id @unique
  email       String       @unique
  name        String
  coffeeShops CoffeeShop[]
  password    String
}

model CoffeeShop {
  id        String   @default(cuid()) @id @unique
  name      String
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  wifi      Boolean
  maxPrice  Float
  minPrice  Float
  openAt    DateTime
  closeAt   DateTime
  address   String
  mapsUrl   String
  createdBy User
  mainImage String
}

typescript: 3.5.2, @prisma/nexus: 0.0.1, prisma2: 0.0.114

[email protected] is same error

[email protected] same error on Linux Mint

After each yarn/npm install operation, the node_modules are made pristine by the respective package managers, this removes all generated code such as Photon. The solution is to use "prisma2 generate" as a postinstall hook.

This document talks more about this design decision.

Please let me know if this issue is fixed for you after adding the postinstall hook.

@divyenduz for me it doesn't resolve the issue :/

[email protected], binary version: 4f33077038a490e4b2c1c260f109309e4a447181

Bildschirmfoto 2019-07-23 um 09 10 33

@ManAnRuck A change in preview-2 requires that you remove the output property from

generator nexus_prisma {
  provider = "nexus-prisma"
  output   = "node_modules/@generated/nexus-prisma"
}

See #143 for details.

🙂 @gihrig after removing output it was working (and remove and reinstall node_modules folders)

It sounds like this can be closed, as removing a hardcoded output fixes it.

Can we use photon in client side app like Angular or React?

Good question @dojsys, you should create a new issue for this question though. Thanks.

Was this page helpful?
0 / 5 - 0 ratings