Cannot find package even installed

AnonymousTRIAL

a year ago

I'm deploying a Discord bot but I'm getting this returned error, the package is installed and working fine on local

0 Replies

a year ago

is it installed in the dependencies or the dev dependencies


AnonymousTRIAL

a year ago

Dependencies


a year ago

is your lock file in sync


AnonymousTRIAL

a year ago

Should be


AnonymousTRIAL

a year ago

```## build runner
FROM node:lts-alpine as build-runner

Set temp directory

WORKDIR /tmp/app

Move package.json

COPY package.json .

Install dependencies

RUN yarn install

Move source files

COPY src ./src
COPY tsconfig.json .
COPY prisma ./prisma

Generate Prisma Client

RUN npx prisma generate

Build project

RUN yarn run build

production runner

FROM node:lts-alpine as prod-runner

Set work directory

WORKDIR /app

Copy package.json from build-runner

COPY --from=build-runner /tmp/app/package.json /app/package.json

Move build files

COPY --from=build-runner /tmp/app/build /app/build

Start bot

CMD [ "yarn", "run", "start" ]
```


AnonymousTRIAL

a year ago

My Dockerfile


a year ago

try utilizing a lock file and install from the lock file


AnonymousTRIAL

a year ago

So I should try sending my yarn.lock together?


a year ago

not sure what you mean by sending


AnonymousTRIAL

a year ago

Commiting together


a year ago

your lock file should definitely be in your repo, and used to install the dependencies from


AnonymousTRIAL

a year ago

Let me try


a year ago

are you sure railway is using your Dockerfile?


AnonymousTRIAL

a year ago

Yes

1243558625058885600


AnonymousTRIAL

a year ago

Not sure if it's using right


a year ago

there's just some simple config issue somewhere with your project


AnonymousTRIAL

a year ago

Even with the yarn.lock file still the same error


a year ago

please show me the updated dockerfile


AnonymousTRIAL

a year ago

Still the same


AnonymousTRIAL

a year ago

1243558982526701600


a year ago

please see my message, this requires you to change the dockerfile a little bit


AnonymousTRIAL

a year ago

```## build runner
FROM node:lts-alpine as build-runner

Set temp directory

WORKDIR /tmp/app

Move package.json and yarn.lock

COPY package.json yarn.lock ./

Install dependencies

RUN yarn install

Move source files

COPY src ./src
COPY tsconfig.json .
COPY prisma ./prisma

Generate Prisma Client

RUN npx prisma generate

Build project

RUN yarn run build

production runner

FROM node:lts-alpine as prod-runner

Set work directory

WORKDIR /app

Copy package.json from build-runner

COPY --from=build-runner /tmp/app/package.json /app/package.json
COPY --from=build-runner /tmp/app/yarn.lock /app/yarn.lock

Move build files

COPY --from=build-runner /tmp/app/build /app/build

Start bot

CMD [ "yarn", "run", "start" ]
```


AnonymousTRIAL

a year ago

What else should I change?


a year ago

install from the lock file


AnonymousTRIAL

a year ago

I don't know how to do that to be honest


AnonymousTRIAL

a year ago

Tried RUN yarn install --frozen-lockfile


a year ago

that is what you would want to be using in a production environment


AnonymousTRIAL

a year ago

And what should I use now?


a year ago

exactly what you just sent


AnonymousTRIAL

a year ago

```## build runner
FROM node:lts-alpine as build-runner

Set temp directory

WORKDIR /tmp/app

Move package.json and yarn.lock

COPY package.json yarn.lock ./

Install dependencies

RUN yarn install --frozen-lockfile

Move source files

COPY src ./src
COPY tsconfig.json .
COPY prisma ./prisma

Generate Prisma Client

RUN npx prisma generate

Build project

RUN yarn run build

production runner

FROM node:lts-alpine as prod-runner

Set work directory

WORKDIR /app

Copy package.json from build-runner

COPY --from=build-runner /tmp/app/package.json /app/package.json
COPY --from=build-runner /tmp/app/yarn.lock /app/yarn.lock

Move build files

COPY --from=build-runner /tmp/app/build /app/build

Start bot

CMD [ "yarn", "run", "start" ]
```


a year ago

please update your dockerfile with this


AnonymousTRIAL

a year ago

Still giving the same error


a year ago

locally, delete your node_modules and then run yarn install --frozen-lockfile and start your project


AnonymousTRIAL

a year ago

Now what?


AnonymousTRIAL

a year ago

No errors


a year ago

what node version are you using locally


AnonymousTRIAL

a year ago

20.11.0


a year ago

what version of node is node:lts-alpine


AnonymousTRIAL

a year ago

I'm not sure, I think it's the last one available


a year ago

its 20.13.1


AnonymousTRIAL

a year ago

So I might need to define the node version?


a year ago

try using node:20.11.0-alpine


a year ago

in your dockerfile, run a prune and then copy the node_modules folder into the final layer


AnonymousTRIAL

a year ago

You mean
COPY --from=build-runner /tmp/app/node_modules /app/node_modules?


a year ago

please take everything i said in this message into account


AnonymousTRIAL

a year ago

Working fine now @Brody


AnonymousTRIAL

a year ago

Thank you so much


a year ago

no problem