adonisjs / core

AdonisJS is a TypeScript-first web framework for building web apps and API servers. It comes with support for testing, modern tooling, an ecosystem of official packages, and more.
https://adonisjs.com
MIT License
16.89k stars 639 forks source link

Docker: "unable to determine transport target for "pino-pretty"" #4729

Closed chichi13 closed 1 month ago

chichi13 commented 1 month ago

Package version

6.13.1

Describe the bug

I have taken the dockerfile from the docs:

FROM node:20.12.2-alpine3.18 as base

# All deps stage
FROM base as deps
WORKDIR /app
ADD package.json package-lock.json ./
RUN npm ci

# Production only deps stage
FROM base as production-deps
WORKDIR /app
ADD package.json package-lock.json ./
RUN npm ci --omit=dev

# Build stage
FROM base as build
WORKDIR /app
COPY --from=deps /app/node_modules /app/node_modules
ADD . .
RUN node ace build

# Production stage
FROM base
ENV NODE_ENV=production
WORKDIR /app
COPY --from=production-deps /app/node_modules /app/node_modules
COPY --from=build /app/build /app
EXPOSE 8080
CMD ["node", "./bin/server.js"]

But when I run it I have the following error:

$ docker run -it --rm --env-file .env -p 3333:3333 adonis-back:v1.0 

   Error: unable to determine transport target for "pino-pretty"

   ⁃ fixTarget
     node_modules/pino/lib/transport.js:146
   ⁃ anonymous
     node_modules/pino/lib/transport.js:93
   ⁃ transport
     node_modules/pino/lib/transport.js:90

Do you have any idea on how can I fix this?

Reproduction repo

private repo

parnaudd commented 1 month ago

Hi everyone,

I can reproduce this manually with a base project by running

node ace build

$ node bin/server.js

 Error: unable to determine transport target for "pino-pretty"

   ⁃ fixTarget
     node_modules/.pnpm/pino@8.21.0/node_modules/pino/lib/transport.js:146
   ⁃ anonymous
     node_modules/.pnpm/pino@8.21.0/node_modules/pino/lib/transport.js:93
   ⁃ transport
     node_modules/.pnpm/pino@8.21.0/node_modules/pino/lib/transport.js:90
parnaudd commented 1 month ago

EDIT: Move pino-pretty from devDependencies to dependencies fixed the issue. But don't know if it's a correct way as the dependencies was put in devDependencies in a base project.

thetutlage commented 1 month ago

Make sure you run your app with NODE_ENV=production when running in production

chichi13 commented 1 month ago

Good point @thetutlage , working with NODE_ENV=production