Cannot find package even installed
Anonymous
TRIALOP

2 years 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

brody
EMPLOYEE

2 years ago

is it installed in the dependencies or the dev dependencies


Anonymous
TRIALOP

2 years ago

Dependencies


brody
EMPLOYEE

2 years ago

is your lock file in sync


Anonymous
TRIALOP

2 years ago

Should be


Anonymous
TRIALOP

2 years 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" ]
```


Anonymous
TRIALOP

2 years ago

My Dockerfile


brody
EMPLOYEE

2 years ago

try utilizing a lock file and install from the lock file


Anonymous
TRIALOP

2 years ago

So I should try sending my yarn.lock together?


brody
EMPLOYEE

2 years ago

not sure what you mean by sending


Anonymous
TRIALOP

2 years ago

Commiting together


brody
EMPLOYEE

2 years ago

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


Anonymous
TRIALOP

2 years ago

Let me try


brody
EMPLOYEE

2 years ago

are you sure railway is using your Dockerfile?


Anonymous
TRIALOP

2 years ago

Yes

1243558625058885600


Anonymous
TRIALOP

2 years ago

Not sure if it's using right


brody
EMPLOYEE

2 years ago

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


Anonymous
TRIALOP

2 years ago

Even with the yarn.lock file still the same error


brody
EMPLOYEE

2 years ago

please show me the updated dockerfile


Anonymous
TRIALOP

2 years ago

Still the same


Anonymous
TRIALOP

2 years ago

1243558982526701600


brody
EMPLOYEE

2 years ago

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


Anonymous
TRIALOP

2 years 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" ]
```


Anonymous
TRIALOP

2 years ago

What else should I change?


brody
EMPLOYEE

2 years ago

install from the lock file


Anonymous
TRIALOP

2 years ago

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


Anonymous
TRIALOP

2 years ago

Tried RUN yarn install --frozen-lockfile


brody
EMPLOYEE

2 years ago

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


Anonymous
TRIALOP

2 years ago

And what should I use now?


brody
EMPLOYEE

2 years ago

exactly what you just sent


Anonymous
TRIALOP

2 years 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" ]
```


brody
EMPLOYEE

2 years ago

please update your dockerfile with this


Anonymous
TRIALOP

2 years ago

Still giving the same error


brody
EMPLOYEE

2 years ago

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


Anonymous
TRIALOP

2 years ago

Now what?


Anonymous
TRIALOP

2 years ago

No errors


brody
EMPLOYEE

2 years ago

what node version are you using locally


Anonymous
TRIALOP

2 years ago

20.11.0


brody
EMPLOYEE

2 years ago

what version of node is node:lts-alpine


Anonymous
TRIALOP

2 years ago

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


brody
EMPLOYEE

2 years ago

its 20.13.1


Anonymous
TRIALOP

2 years ago

So I might need to define the node version?


brody
EMPLOYEE

2 years ago

try using node:20.11.0-alpine


brody
EMPLOYEE

2 years ago

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


Anonymous
TRIALOP

2 years ago

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


brody
EMPLOYEE

2 years ago

please take everything i said in this message into account


Anonymous
TRIALOP

2 years ago

Working fine now @Brody


Anonymous
TRIALOP

2 years ago

Thank you so much


brody
EMPLOYEE

2 years ago

no problem


Loading...