blitz-js / legacy-framework

MIT License
3 stars 2 forks source link

Cannot find module '@prisma/client' after installing Recipe #535

Closed birksy89 closed 3 years ago

birksy89 commented 3 years ago

What is the problem?

After installing the tailwind Recipe, I encountered this error when trying to load a page

"Error: Cannot find module '.prisma/client'"

I discovered this pre-existing issue when searching, and it seems to be strongly connected: https://github.com/prisma/prisma-client-js/issues/560

Following the step / command in that issue does seem to solve the problem, but I'm not sure if it is the correct action to take:

To fix this, you need to run ./node_modules/.bin/prisma2 generate

Steps to Reproduce

  1. Have a working project
  2. Install Tailwind Recipe via blitz install tailwind
  3. Follow CLI prompts
  4. Run the application blitz start
  5. Navigate to initial page

Versions

Windows 10 | win32-x64 | Node: v12.16.0

blitz: 0.29.2 (global)
blitz: 0.29.2 (local)

  Package manager: yarn
  System:
    OS: Windows 10 10.0.18363
    CPU: (8) x64 Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
    Memory: 7.77 GB / 15.95 GB
  Binaries:
    Node: 12.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.15.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.11 - ~\AppData\Roaming\npm\npm.CMD
    Watchman: Not Found
  npmPackages:
    @prisma/cli: ~2.14 => 2.14.0
    @prisma/client: ~2.14 => 2.14.0
    blitz: 0.29.2 => 0.29.2
    react: 0.0.0-experimental-3310209d0 => 0.0.0-experimental-3310209d0
    react-dom: 0.0.0-experimental-3310209d0 => 0.0.0-experimental-3310209d0
    typescript: 4.1.3 => 4.1.3

Other

image

flybayer commented 3 years ago

Usually prisma will automatically run npx prisma generate for you, but sometimes that fails as you can see. The solution is indeed to run npx prisma generate.

aravindballa commented 3 years ago

I had the same issue. npx prisma generate fixed it. I installed Tailwind recipe soon after generating a blitz app.

maietta commented 1 year ago

I wasted nearly 2 days on this problem trying to isolate it.

Turns out, Prisma does NOT work with SvelteKit using NPM in production in some very limited circumstances. (I'm building for SSR and deploying using the Node adaptor to my CapRover instances).

This is the fix:

Ditch NPM for building and instead switch to yarn.

npm i -g yarn.

Your commands like npm run dev will now become yarn dev

Update any workflows to use yarn build, yarn test, etc. Get rid of the --if-present if you use that.

But first, you'll also need to dump the node_modules/ directory as well as your package-lock.json.

Run yarn install and you are good to go.

Screw you, npm. I'm done with you!

haleybarlar commented 11 months ago

I had the same issue. npx prisma generate fixed it. I installed Tailwind recipe soon after generating a blitz app.

That solved it for me. Thank you @aravindballa

RinNguyens commented 5 months ago

Usually prisma will automatically run npx prisma generate for you, but sometimes that fails as you can see. The solution is indeed to run npx prisma generate.

Wow, thanks for answer. That solved for me.