tsx: Watch not working with docker
Bug description
I have created one file named main.ts and am using tsx watch ./main.ts as my start script to watch the file. Locally everything is working fine (Node 20) but when I try to run in a docker container, it does not watch changes in main.ts.
I have mounted my local files to container.
I was expecting it to reload when I make changes in main.ts locally.
Nothing happens. tsx does not reload anything.
I did not get any error
Reproduction
This is my main.ts
console.log('Hello world!');
This is my Dockerfile (I have tried with node:alpine too)
FROM node:18-alpine
WORKDIR /app
COPY package.json .
COPY package-lock.json .
RUN npm install
COPY . .
CMD [ "npm", "run", "start"]
This is the docker-compose.yml
version: '3.8'
services:
tsx-test:
build: .
volumes:
- .:/app
- nodeModules:/app/node_modules
volumes:
nodeModules:
Environment
System:
OS: Windows 10 10.0.22621
CPU: (8) x64 Intel(R) Core(TM) i5-9300H CPU @ 2.40GHz
Memory: 1.23 GB / 7.85 GB
Binaries:
Node: 20.1.0 - C:\Program Files\nodejs\node.EXE
Yarn: 3.5.1 - C:\Program Files\nodejs\yarn.CMD
npm: 9.6.4 - C:\Program Files\nodejs\npm.CMD
pnpm: 8.6.7 - C:\Program Files\nodejs\pnpm.CMD
npmPackages:
tsx: ^3.12.7 => 3.12.7
BTW, I am using Windows 11 not 10
Can you work on a fix?
- I’m interested in opening a pull request to address this issue.
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 2
- Comments: 16 (4 by maintainers)
I checked @parcel/watcher and it also does not work with Docker on windows.
In fact, no watcher can actually handle this. The problem is in Windows, Docker uses WSL2 which uses its own file system (ext4 for Ubuntu) instead of windows NTFS. So, when I change something locally in windows, change happens in NTFS but container running in ext4 never gets notified of the change because of this bug in WSL: [WSL2] File changes made by Windows apps on Windows filesystem don’t trigger notifications for Linux apps.
So, until that issue is fixed (which will definitely take a long time) we have a few options:
I think switching to @parcel/watcher is actually a better long term option as Chokidar is a bit less active now.
Okay, lets add a --poll flag that accepts a interval value.