Reputation: 360
I am using Nestjs Mono repo and I am trying to live reload with docker-compose.
Here is my Dockerfile
FROM node:16
ENV NODE_ENV=development
WORKDIR /app
COPY package.json ./
RUN npm install
COPY . .
And this is my service in docker-compose.yml
auth:
build:
context: ./
dockerfile: ./apps/auth/Dockerfile.dev
volumes:
- ./apps:/app/apps
command: npm start
Here is the start command
nest start --watch
Service is working but it is not reloading on changes
Live reloading works properly on my local machine and in container if I don't use volume.
Nestjs version: 8.1.5
Update:
I have opened an issue of nestjs/cli
Upvotes: 7
Views: 5333
Reputation: 51
For future references: Hot reload error.
When you're using the NestJS CLI to start your application in watch mode it is done by calling tsc --watch, and as of version 4.9 of TypeScript, a new strategy for detecting file changes is used which is likely to be the cause of this problem. In order to fix this problem, you need to add a setting to your tsconfig.json file after the "compilerOptions" option as follows:
"watchOptions": {
"watchFile": "fixedPollingInterval"
}
Upvotes: 2
Reputation: 1170
It's late but can help others. you can add options to NestJS webpack's config
look at this reference about to config it: https://docs.nestjs.com/recipes/hot-reload
and when you did, add this options (your config file has to be like this):
module.exports = function (options) {
options.watchOptions = {
poll: 1000,
aggregateTimeout: 300,
}
return options
};
you don't need to install dependencies that were told in the document (those are just for example). only install webpack
as --save-dev
Upvotes: 1
Reputation: 23
This may me a bit late, I had the same issue and i have tried all the available solutions and the only one that worked for me that was mentioned by @jbool24 at https://stackoverflow.com/a/73476289/4910054
solution is to start the nest with --tsc :
"start:dev": "nest start --tsc --watch"
Upvotes: 1