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

On fly.io with v2.6.0, Cannot find module '@prisma/client' on build #2248

Closed
paulrudy opened this issue Aug 30, 2023 · 7 comments
Closed

On fly.io with v2.6.0, Cannot find module '@prisma/client' on build #2248

paulrudy opened this issue Aug 30, 2023 · 7 comments

Comments

@paulrudy
Copy link

Describe the Bug

Deploying on fly.io after having upgraded from v2.5.0 to v2.6.0, the deploy crashes with Cannot find module '@prisma/client'

Database

PostgreSQL

Relevant log output

$ node scripts/check-db.js
  node:internal/modules/cjs/loader:1080
    throw err;
    ^
  Error: Cannot find module '@prisma/client'
  Require stack:
  - /app/scripts/check-db.js
      at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
      at Module._load (node:internal/modules/cjs/loader:922:27)
      at Module.require (node:internal/modules/cjs/loader:1143:19)
      at require (node:internal/modules/cjs/helpers:121:18)
      at Object.<anonymous> (/app/scripts/check-db.js:3:26)
      at Module._compile (node:internal/modules/cjs/loader:1256:14)
      at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
      at Module.load (node:internal/modules/cjs/loader:1119:32)
      at Module._load (node:internal/modules/cjs/loader:960:12)
      at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ '/app/scripts/check-db.js' ]
  }
  Node.js v18.17.1
  error Command failed with exit code 1.
  info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

Fly.io

@mikecao
Copy link
Collaborator

mikecao commented Aug 31, 2023

I'm not familiar with Fly.io, is there a build step somewhere in the deployment? You need to do a yarn install to get the dependencies, unless you're using docker.

@paulrudy
Copy link
Author

paulrudy commented Aug 31, 2023

Hi @mikecao, thanks. Yes, Fly.io uses a Dockerfile to build a VM (but not a Docker container). I use Umami's repo with its Dockerfile to build Umami on Fly, with just one line added to make it compatiblae (RUN apk --update add postgresql-client). I've been having no issues with multiple versions of Umami until upgrading from v2.5.0 to v2.6.0.

Edit: So to be clear, the build step is virtually identical to the build described in the Umami's Dockerfile.

@mikecao
Copy link
Collaborator

mikecao commented Aug 31, 2023

In v2.6.0 we upgraded Prisma to v5.2.0. Since the error is complaining about @prisma/client, it's possible there is some conflict with the environment and the Prisma version. Quick way to test would be to downgrade Prisma to v5.0.0 during the build process.

@paulrudy
Copy link
Author

paulrudy commented Sep 1, 2023

I edited

RUN yarn add npm-run-all dotenv prisma

to

RUN yarn add npm-run-all dotenv prisma@~5.0.0

but unfortunately the problem persists.

I read elsewhere that prisma can cause memory spikes, so I tried increasing the VM's RAM to 1024 from 512, but this didn't help either.

@paulrudy
Copy link
Author

paulrudy commented Sep 1, 2023

Further info:

My fly.io build process injects yarn check-db as the entrypoint for the VM, as outlined here, and that's worked through Umami v2.5.0. With v2.6.x, that produces the error Cannot find module '@prisma/client' on build.

If I replace that entrypoint with yarn start-docker, I get Cannot find module '/app/node_modules/semver/index.js'. Please verify that the package.json has a valid "main" entry

@paulrudy
Copy link
Author

paulrudy commented Sep 18, 2023

Thanks to this comment, I switched to using the prebuilt postgres Umami container, and everything works fine now.

Previously I had been pulling from Umami source and deploying that with a small modification in the Dockerfile, plus a fly.toml file. That had worked until v2.6.x. But deploying from the pre-built container is simpler, and is working fine now.

@paulrudy
Copy link
Author

Closed

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

2 participants