React Remix - Issue with finding @prisma/client module

I am not sure what the issue could be. I only update the Prisma client and have tried multiple things to try and get this working.

I have to rollback to earlier versions of my deployment. I haven’t changed the code for using Prisma at all.

 1 desired, 1 placed, 0 healthy, 1 unhealthy [restarts: 2] [health checks: 1 total]
Failed Instances

Failure #1

Instance
ID              PROCESS VERSION REGION  DESIRED STATUS  HEALTH CHECKS   RESTARTS        CREATED 
9bc0bcfb        app     159     iad     run     pending 1 total         2               48s ago

Recent Events
TIMESTAMP               TYPE            MESSAGE                         
2022-12-27T15:57:07Z    Received        Task received by client        
2022-12-27T15:57:30Z    Task Setup      Building Task Directory        
2022-12-27T15:57:39Z    Started         Task started by client         
2022-12-27T15:57:43Z    Terminated      Exit Code: 1                   
2022-12-27T15:57:43Z    Restarting      Task restarting in 1.008544036s
2022-12-27T15:57:50Z    Started         Task started by client         
2022-12-27T15:57:54Z    Terminated      Exit Code: 1                   
2022-12-27T15:57:54Z    Restarting      Task restarting in 1.006305876s

2022-12-27T15:58:00Z   [info]Configuring virtual machine
2022-12-27T15:58:00Z   [info]Pulling container image
2022-12-27T15:58:00Z   [info]Unpacking image
2022-12-27T15:58:00Z   [info]Preparing kernel init
2022-12-27T15:58:00Z   [info]Setting up volume 'remix_data'
2022-12-27T15:58:00Z   [info]Opening encrypted volume
2022-12-27T15:58:00Z   [info]Configuring firecracker
2022-12-27T15:58:00Z   [info]Starting virtual machine
2022-12-27T15:58:01Z   [info]Starting init (commit: f447594)...
2022-12-27T15:58:01Z   [info]Mounting /dev/vdc at /app/sessions w/ uid: 0, gid: 0 and chmod 0755
2022-12-27T15:58:01Z   [info]Preparing to run: `docker-entrypoint.sh npm start` as root
2022-12-27T15:58:01Z   [info]2022/12/27 15:58:01 listening on [fdaa:0:8864:a7b:21e0:2:b3d1:2]:22 (DNS: [fdaa::3]:53)
2022-12-27T15:58:01Z   [info]> start
2022-12-27T15:58:01Z   [info]> remix-serve build
2022-12-27T15:58:02Z   [info]Error: Cannot find module '@prisma/client'
2022-12-27T15:58:02Z   [info]Require stack:
2022-12-27T15:58:02Z   [info]- /app/build/index.js
2022-12-27T15:58:02Z   [info]- /app/node_modules/@remix-run/serve/dist/cli.js
2022-12-27T15:58:02Z   [info]    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
2022-12-27T15:58:02Z   [info]    at Function.Module._load (node:internal/modules/cjs/loader:841:27)
2022-12-27T15:58:02Z   [info]    at Module.require (node:internal/modules/cjs/loader:1067:19)
2022-12-27T15:58:02Z   [info]    at require (node:internal/modules/cjs/helpers:103:18)
2022-12-27T15:58:02Z   [info]    at Object.<anonymous> (/app/build/index.js:313:21)
2022-12-27T15:58:02Z   [info]    at Module._compile (node:internal/modules/cjs/loader:1165:14)
2022-12-27T15:58:02Z   [info]    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1219:10)
2022-12-27T15:58:02Z   [info]    at Module.load (node:internal/modules/cjs/loader:1043:32)
2022-12-27T15:58:02Z   [info]    at Function.Module._load (node:internal/modules/cjs/loader:878:12)
2022-12-27T15:58:02Z   [info]    at Module.require (node:internal/modules/cjs/loader:1067:19)
2022-12-27T15:58:03Z   [info]Starting clean up.
2022-12-27T15:58:03Z   [info]Umounting /dev/vdc from /app/sessions
--> v159 failed - Failed due to unhealthy allocations - rolling back to job version 158 and deploying as v160 

--> Troubleshooting guide at https://fly.io/docs/getting-started/troubleshooting/
Error abort

This is my package.json

{
  "private": true,
  "sideEffects": false,
  "scripts": {
    "build": "npm run build:css && remix build",
    "build:css": "tailwindcss -m -i ./styles/tailwind.css -o app/styles/tailwind.css",
    "deploy": "fly deploy --remote-only",
    "dev": "concurrently \"npm run dev:css\" \"remix dev\"",
    "dev:css": "tailwindcss -w -i ./styles/tailwind.css -o app/styles/tailwind.css",
    "start": "remix-serve build"
  },
  "dependencies": {
    "@remix-run/node": "^1.7.2",
    "@remix-run/react": "^1.7.2",
    "@remix-run/serve": "^1.7.0",
    "@sendgrid/mail": "^7.7.0",
    "@stripe/react-stripe-js": "^1.10.0",
    "@stripe/stripe-js": "^1.35.0",
    "@tailwindcss/line-clamp": "^0.4.2",
    "@tiptap/react": "^2.0.0-beta.114",
    "@tiptap/starter-kit": "^2.0.0-beta.191",
    "algoliasearch": "^4.14.2",
    "aws-sdk": "^2.1235.0",
    "dayjs": "^1.11.5",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-google-forms-hooks": "^1.2.4",
    "react-hot-toast": "^2.4.0",
    "react-instantsearch-hooks-web": "^6.32.1",
    "react-iubenda-policy": "^0.1.1",
    "remix": "^1.7.2",
    "remix-utils": "^3.3.0",
    "sanitize-html": "^2.7.2",
    "stripe": "^10.6.0",
    "tailwind": "^4.0.0"
  },
  "devDependencies": {
    "@prisma/client": "^4.8.0",
    "@remix-run/dev": "^1.7.0",
    "@remix-run/eslint-config": "^1.7.0",
    "@tailwindcss/forms": "^0.5.3",
    "@types/react": "^18.0.15",
    "@types/react-dom": "^18.0.6",
    "@types/sanitize-html": "^2.6.2",
    "@types/sharp": "^0.31.0",
    "autoprefixer": "^10.4.8",
    "concurrently": "^7.3.0",
    "dotenv": "^16.0.3",
    "eslint": "^8.20.0",
    "i": "^0.3.7",
    "npm": "^9.2.0",
    "postcss": "^8.4.16",
    "prisma": "^4.8.0",
    "tailwindcss": "^3.1.8",
    "typescript": "^4.7.4"
  },
  "engines": {
    "node": ">=14"
  }
}

This is my docker file

# base node image

FROM node:16-bullseye-slim as base

# set for base and all layer that inherit from it

ENV NODE_ENV production

# Install openssl for Prisma

RUN apt-get update && apt-get install -y openssl && apt-get install -y ca-certificates

# Install all node_modules, including dev dependencies

FROM base as deps

WORKDIR /app

ADD package.json package-lock.json ./

RUN npm install --production=false

# Setup production node_modules

FROM base as production-deps

WORKDIR /app

COPY --from=deps /app/node_modules /app/node_modules

ADD package.json package-lock.json ./

RUN npm prune --production

# Build the app

FROM base as build

WORKDIR /app

COPY --from=deps /app/node_modules /app/node_modules

ADD prisma .

RUN npx prisma generate

ADD . .

RUN npm run build

# Finally, build the production image with minimal footprint

FROM base

WORKDIR /app

COPY --from=production-deps /app/node_modules /app/node_modules

COPY --from=build /app/node_modules/.prisma /app/node_modules/.prisma

COPY --from=build /app/build /app/build

COPY --from=build /app/public /app/public

ADD . .

CMD ["npm", "start"]

As always…it was an easy bug.

@prisma/client was installed as a dev dependency for some reason when I updated it. Removed it and installed again and it was all working.