I have hosted a Discord Bot on Fly, and it uses discord.js v13.10.3. It is specified in the package.json file. However when I build and deploy the project it installs discordjs v13.6.0!!!
I’m not sure why is this happening. It is working well and using correct version on my local PC.
My project uses a Dockerfile.
Do you have a package-lock.json file? Is it checked in as well? Is your package.json file explicitly specifying the version?
It would help if you provided more information like your package.json file and your Dockerfile. The Dockerfile specifies which version of Node is being installed as well.
There may be other dependencies in package.json that cause it to fetch an older version. Try deleting your node_modules folder locally and doing the same command to install it. It may replicate the problem.
Consider an npm install command like this in Docker RUN npm ci --progress=false --no-audit --loglevel=error. It likely won’t fix your problem at all, but it’s a more Docker friendly way to run it.
@Mark I fixed the problem finally, thanks for your help. But now I need another help.
I have a config directory where all bot config files are stored. The bot gets deployed in /app (according to Dockerfile), and I’ve created a volume at /data. I want to store the config directories to /data and symlink them to /app.
This is my Dockerfile right now:
FROM node:18-buster
WORKDIR /data
COPY config .
COPY storage .
WORKDIR /app
COPY package.json .
COPY package-lock.json .
COPY tsconfig.json .
COPY init.sh .
COPY src ./src
RUN npm ci --progress=false --no-audit --loglevel=error
RUN npm run build
COPY . .
RUN rm -rf config storage
RUN ln -s /data/config
RUN ln -s /data/storage
COPY . .
EXPOSE 4000
CMD ["npm", "run", "start:node"]
Now how do I store the config files to /data? It does not actually store any data to /data and does not give any errors.