I have the following Dockerfile:
FROM node:latest
WORKDIR /usr/src/app
ENV NODE_ENV=production
COPY package*.json .
RUN npm install && npm i -g typescript
COPY . .
RUN tsc
CMD [ "node", "./dist/index.js" ]
And the following package.json:
"dependencies": {
"discord.js": "^12.5.3",
"moment": "^2.29.1"
},
"devDependencies": {
"@types/node": "^14.14.37",
"typescript": "^4.2.4"
}
When I try to build the image, I get the following error:
Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`
Does anyone know why that happens? I have @types/node installed.
devDependencies won't be installed for production mode.
So, you can:
dependencies orNODE_ENV environment variable orproduction here), and use JS files on the second stage (you don't need devDependencies here, so, production will work).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With