I am trying to print the current package.json version inside my node.js app.
When I run it locally it works fine using process.env.npm_package_version.
However when I build it using a Dockerfile and then deploying it to a container the process.env.npm_package_version variable is undefined. Does anyone know what is going on?
My dockerfile:
FROM node:16.13.2
ENV NODE_ENV production
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
CMD ["npm", "start"]
Part of my package.json:
"name": "node-discord-bot",
"version": "2.2.4",
"description": "",
"main": "./build/server.js",
"scripts": {
"start": "node .",
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc"
},