Cannot find package even installed
vitagliano
HOBBYOP

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

48 Replies

2 years ago

is it installed in the dependencies or the dev dependencies


vitagliano
HOBBYOP

2 years ago

Dependencies


2 years ago

is your lock file in sync


vitagliano
HOBBYOP

2 years ago

Should be


vitagliano
HOBBYOP

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


vitagliano
HOBBYOP

2 years ago

My Dockerfile


2 years ago

try utilizing a lock file and install from the lock file


vitagliano
HOBBYOP

2 years ago

So I should try sending my yarn.lock together?


2 years ago

not sure what you mean by sending


vitagliano
HOBBYOP

2 years ago

Commiting together


2 years ago

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


vitagliano
HOBBYOP

2 years ago

Let me try


2 years ago

are you sure railway is using your Dockerfile?


vitagliano
HOBBYOP

2 years ago

Yes

1243558625058885600


vitagliano
HOBBYOP

2 years ago

Not sure if it's using right


2 years ago

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


vitagliano
HOBBYOP

2 years ago

Even with the yarn.lock file still the same error


2 years ago

please show me the updated dockerfile


vitagliano
HOBBYOP

2 years ago

Still the same


vitagliano
HOBBYOP

2 years ago

1243558982526701600


2 years ago

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


vitagliano
HOBBYOP

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


vitagliano
HOBBYOP

2 years ago

What else should I change?


2 years ago

install from the lock file


vitagliano
HOBBYOP

2 years ago

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


vitagliano
HOBBYOP

2 years ago

Tried RUN yarn install --frozen-lockfile


2 years ago

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


vitagliano
HOBBYOP

2 years ago

And what should I use now?


2 years ago

exactly what you just sent


vitagliano
HOBBYOP

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


2 years ago

please update your dockerfile with this


vitagliano
HOBBYOP

2 years ago

Still giving the same error


2 years ago

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


vitagliano
HOBBYOP

2 years ago

Now what?


vitagliano
HOBBYOP

2 years ago

No errors


2 years ago

what node version are you using locally


vitagliano
HOBBYOP

2 years ago

20.11.0


2 years ago

what version of node is node:lts-alpine


vitagliano
HOBBYOP

2 years ago

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


2 years ago

its 20.13.1


vitagliano
HOBBYOP

2 years ago

So I might need to define the node version?


2 years ago

try using node:20.11.0-alpine


2 years ago

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


vitagliano
HOBBYOP

2 years ago

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


2 years ago

please take everything i said in this message into account


vitagliano
HOBBYOP

2 years ago

Working fine now @Brody


vitagliano
HOBBYOP

2 years ago

Thank you so much


2 years ago

no problem


Loading...