Nundy / doesn-t-hot-reload-issue

NestJs doesn't hot reload work in inside Docker
1 stars 0 forks source link

npm run start:dev is not working in docker #1

Open junjielyu13 opened 1 year ago

junjielyu13 commented 1 year ago

I saw your issue https://github.com/nestjs/nest/issues/11010 and I encountered the same problem, start:dev can't run in docker, I ended up using nodemon instead of star:dev

This might not be the best way, but it works! !

make some changes on scripts in the package.json file:

  1. install nodemon: npm install typescript @types/node ts-node nodemon -D
  2. opt1: Change: "start:dev": "nest start --watch" to "start:dev": "nodemon --legacy-watch -x ts-node src/main.ts"
  3. opt2: Add a script: "nodemon": "nodemon --legacy-watch -x ts-node src/main.ts"

there is a reference:

Hope this helps you

FelipeCO14 commented 1 year ago

It is absurd that nest is so buggy for something so essential and yet so simple as hot reloading when using docker...

I was thinking about using nodemon and this worked perfectly.

since I am using the setup with nestjs monorepo, I pass the main.ts path as a parameter to the command:

package.json

"nodemon": "nodemon --legacy-watch -x ts-node"

docker-compose

command: npm run nodemon -- apps/orders/src/main.ts

I notice moduleNameMapper is no longer working though. Not sure why, but I am fine without it.

opexu commented 1 year ago

I solved the problem by replacing "typescript": "^4.7.4" to "typescript": "~4.7.4" and npm install again locally. I don't now what is the bug.

ramkrishna500 commented 1 year ago

https://stackoverflow.com/questions/76483532/docker-volume-is-not-reflecting-changes

plz solve this

sinanovicanes commented 3 weeks ago

I had the same issue. Fixed by updating start:dev command in package.json with "start:dev": "nest start --tsc --watch" and adding watch options in tsconfig.json

"watchOptions": {
    "watchFile": "fixedPollingInterval"
  }