Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found #5

Open
michaelpomogajko opened this issue Aug 7, 2023 · 17 comments
Open

Module not found #5

michaelpomogajko opened this issue Aug 7, 2023 · 17 comments

Comments

@michaelpomogajko
Copy link

Hi,
although installed, it seems that the module is not being found when importing.

Screenshot 2023-08-07 at 14 19 40 Screenshot 2023-08-07 at 14 21 42 Screenshot 2023-08-07 at 14 24 38
@JoeRoddy
Copy link
Collaborator

JoeRoddy commented Aug 7, 2023

Hi @michaelpomogajko !

There's a janky generate command that you have to run to create your Bridg client along with your Prisma client (this will be replaced in time with a Prisma generator). Not sure if you ran that, or if it failed maybe?

{
  "scripts": {
    "generate": "npx prisma generate && npm explore bridg -- npm run generate"
  }
}

Now that I think about this, there should definitely be some sort of default index.js though, that emits some sort of error telling you that the client hasn't been generated

@michaelpomogajko
Copy link
Author

michaelpomogajko commented Aug 7, 2023

I did ran it, it generated the tmp folder in the package as seen in the last image

@JoeRoddy
Copy link
Collaborator

JoeRoddy commented Aug 7, 2023

Ah, I see, thanks. Was there any error output from the generate command?

If you're on windows, can you try installing this version of Bridg and letting me know if it fixes it for you?

npm install [email protected]
npm run generate

There was an issue in the past with the generate command on Windows machines. I thought I fixed it, but it's possible you might need to use WSL as a temporary fix.

If not, could you possibly give me some more info about your project, OS, etc?

Did you clone one of the example apps, or setting it up on your own? I see you're using Next, which is definitely the framework I've tested out the most. But it's possible there's an issue with specific versions.

Any chance you could create an example repo that reproduces the issue?

Thanks so much opening this, will try to figure out whatever is causing it ASAP.

@michaelpomogajko
Copy link
Author

Hi, yeah I'm receiving the following error when running the generate command

➜  bridg-test git:(main) ✗ yarn generate
yarn run v1.22.19
warning ../../package.json: No license field
$ npx prisma generate && npm explore bridg -- npm run generate
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
warn Preview feature "extendedWhereUnique" is deprecated. The functionality can be used without specifying it as a preview feature.

✔ Generated Prisma Client (5.1.1 | library) to ./node_modules/@prisma/client in 45ms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

> [email protected] generate
> npm run generate-ts && npm run build-client


> [email protected] generate-ts
> node ./dist/generator/index.js ../../prisma/schema.prisma --outDir ./tmp


> [email protected] build-client
> tsc ./tmp/**/*.ts --declaration --outDir ./ && mv client/* ./ && rm -rf ./tmp && rm -rf ./client

../@types/react-dom/node_modules/@types/react/index.d.ts:3244:14 - error TS2300: Duplicate identifier 'ElementType'.

3244         type ElementType = string | React.JSXElementConstructor<any>;
                  ~~~~~~~~~~~

  ../@types/react/index.d.ts:3244:14
    3244         type ElementType = string | React.JSXElementConstructor<any>;
                      ~~~~~~~~~~~
    'ElementType' was also declared here.

< --- shortened due to size --->

  ../@types/react/index.d.ts:3444:13
    3444             view: React.SVGProps<SVGViewElement>;
                     ~~~~
    'view' was also declared here.


Found 185 errors in 3 files.

Errors  Files
     3  ../@types/react-dom/node_modules/@types/react/index.d.ts:3244
     3  ../@types/react/index.d.ts:3244
   179  ../../../../node_modules/@types/react/index.d.ts:3234
npm ERR! code 2
npm ERR! path /Users/mpomogajko001/Desktop/bridg-test/node_modules/bridg
npm ERR! command failed
npm ERR! command sh -c npm run generate

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mpomogajko001/.npm/_logs/2023-08-08T09_39_26_556Z-debug-0.log
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
➜  bridg-test git:(main) ✗

Here's the example repo
https://github.com/michaelpomogajko/bridg-example

I'm on a M1 Mac
Node v16

@JoeRoddy
Copy link
Collaborator

JoeRoddy commented Aug 8, 2023

Oh jeeze, I'm really sorry I missed this when you initially posted the package.json. This is a known issue with Prisma 5. I'm hoping to have a fix out this weekend (when I'm not swamped with my actual job, hah).

https://github.com/JoeRoddy/bridg/blob/main/README.md#add-bridg-to-an-existing-project
image

I think I've tested up to 4.13.0 and had that working, no promises past that. Sorry again, you provided enough detail in your initial comment that I should've caught that.

@michaelpomogajko
Copy link
Author

Downgraded to prisma 4 and still receive an error when running the custom generate
This time it's:

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

I'n on a MacBook M1 with 64GB RAM

@JoeRoddy
Copy link
Collaborator

JoeRoddy commented Aug 9, 2023

Ok thanks, I can take a look tonight and see if I can repro. I have seen that error before, but it was when I used newer versions of Prisma.

What version of Prisma are you using where you see that? Did you try 4.10.1 by any chance?

You could also try updating the script to enforce a specific version of the prisma cli, just in case:
npx [email protected] generate && ..

I know what's causing the out of memory error (it's basically trying to compile all of prisma's ts files and all their dependencies, which it shouldn't need to), hoping to have a big rewrite out this weekend that ideally will fix that issue and allow newer versions to work, and make it easier to setup Bridg in the first place.

Really sorry you're having so many issues with this, would really like to get this fixed for you so you can try it out.

@michaelpomogajko
Copy link
Author

I did try it with the latest @4.x.x version of prisma.

No rush, I'm just trying it out since I'm really excited about the approach the library takes. Actually thought of something like this myself couples months ago, but didn't have the skills to actually do it 😄

Happy that I can help with testing

@JoeRoddy
Copy link
Collaborator

JoeRoddy commented Aug 9, 2023

Yeah I think the issue started happening in a higher version of 4, and still exists in Prisma 5. The latest 4.x would def have the issue too. I'm not sure of the exact version of Prisma where that heap error started happening though.

Try out 4.10.1 when you get a chance and lmk if that fixes it for you!

100% appreciate your help 🙌

@JoeRoddy
Copy link
Collaborator

@michaelpomogajko If you get a chance at some point, I just dropped a big rewrite. Bridg now uses a prisma generator to create the client, instead of that janky generate script. Prisma 5+ is now supported as well. (dropping support on earlier versions going forward, just so I can focus my efforts)

Installing:

schema.prisma:

generator client {
  provider = "prisma-client-js"
}

// Add this UNDER your prisma client
generator bridg {
  provider = "bridg"
}

npx prisma generate

@michaelpomogajko
Copy link
Author

hi @JoeRoddy, tested it and it works out of the box. Thanks!
I'll play around it some more and see If I can hack the caching we talked about

@JoeRoddy
Copy link
Collaborator

If anyone else runs into this issue, make sure you update Bridg and Prisma, instructions here: #5 (comment)

Thanks again for opening this Michael!

@bherbruck
Copy link

bherbruck commented Dec 22, 2023

I'm still having issues with this on the demo bridg-example-nextjs demo:

npm run generate

> [email protected] generate
> prisma generate

Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Error: Generator "bridg" failed:
{
  "name": "next-testing",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "generate": "prisma generate",
    "push": "npx prisma db push"
  },
  "dependencies": {
    "@next/font": "13.1.4",
    "@types/node": "18.11.18",
    "@types/react": "18.0.27",
    "@types/react-dom": "18.0.10",
    "bridg": "1.1.0",
    "eslint": "8.32.0",
    "eslint-config-next": "13.1.4",
    "next": "^13.5.6",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "typescript": "4.9.4"
  },
  "devDependencies": {
    "@prisma/client": "5.1.1",
    "prisma": "5.1.1"
  }
}

generate is not working on any version of prisma I have tried

@JoeRoddy
Copy link
Collaborator

JoeRoddy commented Dec 23, 2023

thanks @bherbruck

Is that the end of the output? it just says: Error: Generator "bridg" failed:?

What operating system are you on?

@JoeRoddy JoeRoddy reopened this Dec 23, 2023
@bherbruck
Copy link

bherbruck commented Dec 23, 2023

What operating system are you on?

I'm on debian in a devcontainer

@JoeRoddy
Copy link
Collaborator

JoeRoddy commented Dec 23, 2023

Thanks for the quick reply! Can I ask which package manager you're using (npm, yarn etc) and what version? Sorry, I forgot to ask in my original reply.

I'm guessing it's likely an OS specific issue though.

@bherbruck
Copy link

I'm using npm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants