#Package not found when deploying to Fly.io

1 messages · Page 1 of 1 (latest)

gusty axle
#

I am trying to deploy a remix app to fly.io, but I keep getting the error below. The app runs fine locally. Any idea what am I missing? I am not using anything from is-buffer.

[info] > start
[info] > remix-serve build
[info] Error: Cannot find module 'is-buffer'

long river
gusty axle
#

I'm using the deploy command that runs fly deploy --remote-only

long river
gusty axle
#

Yes, I ran fly launch first.

This is fly.toml:

# fly.toml file generated for myapp on 2023-01-17T01:16:44+01:00

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

[env]
  PORT = "8080"

[experimental]
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

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

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

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

And the docker file:

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

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

# 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

ENV NODE_ENV=production

RUN mkdir /app
WORKDIR /app

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

# If we're using Prisma, uncomment to cache the prisma schema
# 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

# Uncomment if using Prisma
# 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"]

Thanks for your help!

#

These ones were autogenerated and I did not change anything.

long river
#

What's the name of the app? "myapp"?

#

Did you get any errors on fly launch? If not, it should have asked you if you wanted create a postgres db.

#

After that it should have asked you if you wanted to deploy.

#

Is that when you got the Cannot find module 'is-buffer' error?

gusty axle
#

I'm not using Prisma nor postgres. I tried running fly launch again and now I'm getting this error 🤔 :

Error: Cannot find module 'is-plain-obj'
#

I'm going to remove the app from Fly and try with a clean build

#

I said yes to deploy when running launch and I get this is-plain-obj error

gusty axle
#

I've been able to successfully deploy a new app I created with npx create-remix@latest, so there might be something on my other app that Fly is not happy about. I'll go piece by piece to see where it breaks

gusty axle
#

I think it has something to do with the react-markdown and axios dependencies (ESM only packages). I also had to remove tiny-invariant

#

I added this to the remix config: serverDependenciesToBundle: [/react-markdown\/.*/, /axios\/.*/],

long river
#

...actually its flyctl doctor -a myapp

#

or just 'flyctl doctor' if you're currently using the app.

gusty axle
#

I just ran it and all checks passed

long river
#

Have you tried installing the missing packages?

gusty axle
#

There is something going on with my deps. After playing a bit with serverDependenciesToBundle and removing tiny-invariant I've been able to deploy

long river
#

You might have to use --legacy-peer-deps when installing those packages.

#

npm i react-markdown --legacy-peer-deps

gusty axle
#

After adding serverDependenciesToBundle: [/react-markdown\/.*/, /axios\/.*/] it`s working fine (the regex helped me avoiding having to add all deps manually). I might have to do what you mention with tiny-invariant though

#

Many thanks for your time to help me with that @long river!

#

I learned some interesting new stuff

long river
#

...it's all the available flyctl commands.