Remix Deployment Fails at prisma/scripts/preinstall-entry.js

I’m trying to deploy my Remix application with an SQLite DB.

I keep getting the error:

2022-01-22T18:05:20.000 [info] Starting virtual machine
2022-01-22T18:05:20.000 [info] Starting init (commit: 0c50bff)...
2022-01-22T18:05:20.000 [info] Mounting /dev/vdc at /data w/ uid: 0, gid: 0 and chmod 0755
2022-01-22T18:05:20.000 [info] Preparing to run: `sh start_with_migrations.sh` as root
2022-01-22T18:05:20.000 [info] 2022/01/22 18:05:20 listening on [fdaa:0:4609:a7b:ab3:0:7ce0:2]:22 (DNS: [fdaa::3]:53)
2022-01-22T18:05:20.000 [info] + npx prisma migrate deploy
2022-01-22T18:05:22.000 [info] internal/modules/cjs/loader.js:905
2022-01-22T18:05:22.000 [info]   throw err;
2022-01-22T18:05:22.000 [info]   ^
2022-01-22T18:05:22.000 [info] Error: Cannot find module '/root/.npm/_npx/523/lib/node_modules/prisma/scripts/preinstall-entry.js'
2022-01-22T18:05:22.000 [info]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
2022-01-22T18:05:22.000 [info]     at Function.Module._load (internal/modules/cjs/loader.js:746:27)
2022-01-22T18:05:22.000 [info]     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
2022-01-22T18:05:22.000 [info]     at internal/main/run_main_module.js:17:47 {
2022-01-22T18:05:22.000 [info]   code: 'MODULE_NOT_FOUND',
2022-01-22T18:05:22.000 [info]   requireStack: []
2022-01-22T18:05:22.000 [info] }
2022-01-22T18:05:22.000 [info] npm ERR! code ELIFECYCLE
2022-01-22T18:05:22.000 [info] npm ERR! errno 1
2022-01-22T18:05:22.000 [info] npm ERR! prisma@3.8.1 preinstall: `node scripts/preinstall-entry.js`
2022-01-22T18:05:22.000 [info] npm ERR! Exit status 1
2022-01-22T18:05:22.000 [info] npm ERR!
2022-01-22T18:05:22.000 [info] npm ERR! Failed at the prisma@3.8.1 preinstall script.
2022-01-22T18:05:22.000 [info] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-01-22T18:05:22.000 [info] npm ERR! A complete log of this run can be found in:
2022-01-22T18:05:22.000 [info] npm ERR!     /root/.npm/_logs/2022-01-22T18_05_22_692Z-debug.log
2022-01-22T18:05:22.000 [info] Install for [ 'prisma@latest' ] failed with code 1
2022-01-22T18:05:23.000 [info] Main child exited normally with code: 1
2022-01-22T18:05:23.000 [info] Starting clean up.
2022-01-22T18:05:23.000 [info] Umounting /dev/vdc from /data
--> v4 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v5

This is what my fly.toml file looks like:

app = "got-jokes"

kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]
  DATABASE_URL = "file:/data/sqlite.db"
  PORT = "8080"
  NODE_ENV = "production"

[experimental]
  allowed_public_ports = []
  auto_rollback = true
  cmd = ["start_with_migrations.sh"]
  entrypoint = ["sh"]
  private_network = true

[[mounts]]
  destination = "/data"
  source = "data"

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

Can you post your Dockerfile?

Thanks for the quick response.

Here is my Dockerfile:

# base node image
FROM node:14-bullseye-slim as base

# Install openssl for Prisma
RUN apt-get update && apt-get install -y openssl

ENV NODE_ENV production

# Install all node_modules, including dev dependencies
FROM base as deps

RUN mkdir /app
WORKDIR /app

ADD package.json package-lock.json ./
RUN npm install --production=false

# Setup production node_modules
FROM base as production-deps

RUN mkdir /app
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

RUN mkdir /app
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

ENV NODE_ENV production

RUN mkdir /app
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", "run", "start"]

Any updates on what may be causing this @joshua ?

I’m not sure offhand. This might be something new with a newer version of Prisma. I’ll try out a fresh app and get back to you. Meanwhile, you might want to try asking on the Remix Discord.

Thanks! I’ll reach out on the remix discord.

Let me know what you find. Appreciate the help!

I tried a fresh app and had no problems. Have you added any newer deps to package.json?

I don’t think so. This is what my package.json file looks like.

{
  "private": true,
  "name": "got-jokes",
  "author": "Sapan Bodiwala",
  "description": "",
  "license": "",
  "prisma": {
    "seed": "node --require esbuild-register prisma/seed.ts"
  },
  "scripts": {
    "build": "remix build",
    "deploy": "fly deploy --remote-only",
    "dev": "remix dev",
    "netlify-dev": "cross-env NODE_ENV=development netlify dev",
    "postinstall": "remix setup node",
    "start": "remix-serve build",
    "db": "npx prisma db push && npx prisma db seed && npx prisma studio"
  },
  "dependencies": {
    "@netlify/functions": "^0.10.0",
    "@prisma/client": "^3.8.1",
    "@remix-run/netlify": "^1.1.1",
    "@remix-run/react": "^1.1.1",
    "bcryptjs": "^2.4.3",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "remix": "^1.1.1"
  },
  "devDependencies": {
    "@remix-run/dev": "^1.1.1",
    "@remix-run/serve": "^1.1.1",
    "@types/bcryptjs": "^2.4.2",
    "@types/react": "^17.0.24",
    "@types/react-dom": "^17.0.9",
    "cross-env": "^7.0.3",
    "esbuild-register": "^3.3.1",
    "prisma": "^3.8.1",
    "typescript": "^4.1.2"
  },
  "engines": {
    "node": ">=14"
  },
  "sideEffects": false
}

Does yours look similar?

Here’s mine with a newer version of Remix. Maybe try that?

{
  "private": true,
  "name": "remix-app-template",
  "description": "",
  "license": "",
  "scripts": {
    "build": "remix build",
    "dev": "remix dev",
    "postinstall": "remix setup node",
    "deploy": "fly deploy --remote-only",
    "start": "remix-serve build"
  },
  "dependencies": {
    "@prisma/client": "^3.8.1",
    "@remix-run/react": "^1.1.3",
    "@remix-run/serve": "^1.1.3",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "remix": "^1.1.3"
  },
  "devDependencies": {
    "@remix-run/dev": "^1.1.3",
    "@types/react": "^17.0.24",
    "@types/react-dom": "^17.0.9",
    "prisma": "^3.8.1",
    "typescript": "^4.1.2"
  },
  "engines": {
    "node": ">=14"
  },
  "sideEffects": false
}

Tried that as well… No luck :frowning:

I was able to get this to work now.

  1. Added .npmrc file with scripts-prepend-node-path=true in it.
  2. Using node 14.8.3, I upgraded npm to v8.4.0 locally (npm install -g npm)
  3. Removed package-lock.json & rm -rf node_modules from project locally
  4. Deleted my fly project on Fly.io
  5. Deleted Dockerfile, .dockerignore, & fly.toml files
  6. Ran npm install locally
  7. Ran npm run build
  8. Ran fly launch and followed the steps to deploy.

It worked. Thanks for your help @joshua

1 Like