-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tsc-watch fails to restart node server on source file changes within a docker bind mount #153
Comments
To narrow down the problem, can you just run it with |
Hi @anthonyorona ! I have actually not that big of an idea how the typescript watcher works under the hood, but I had the same issue that my changes on the typescript files on a Windows Host didn't trigger any tsc-watch rebuilds inside my docker container based on the However, even though it is probably a less CPU friendly way, things worked for me as soon as I've explicitly set the
|
@anthonyorona Can you confirm @oelerpearler's solution? |
Bump before closing |
the problem persists, this issue needs to be reopened, it seems like tsc-watch is not working properly with docker's container anymore |
@YouneLL @anthonyorona Can any of you provide an example of the failure? |
There is no failure, tsc-watch simply doesn't restart after files have changed. |
Can someone please provide an example? |
This is my workaround: tsconfig.json {
// ...
"watchOptions": {
"excludeDirectories": ["**/node_modules", "dist"]
},
} Dockerfile # ...
CMD npm run dev -- --watchFile dynamicPriorityPolling --watchDirectory dynamicPriorityPolling I wasn't able to use Dockers exec form, it somehow messes up arguments |
@gilamran Maybe synced changes don't trigger native file events within container that typescript relies on by default. This may be also Windows host - only issue as I'm on Windows 10 Related issue: microsoft/TypeScript#54144 |
yea, ok so the reason is probably what @piotr-cz mentioned: microsoft/TypeScript#54144 |
Since docker 2.22.0 it's possible to use docker compose watch feature without bind mounts and # docker-compose.yml
services:
app:
build: .
command: npm run dev -- --noClear
develop:
watch:
- action: sync
path: ./src
target: /usr/src/app/src
ignore:
- node_modules/
- action: rebuild
path: package.json
target: /usr/src/app command: docker compose up --build --watch Docs: |
host platform: Ubuntu 20.04.5 LTS
container platform: node:16-alpine
run command:
"dev": "tsc-watch --noClear -p ./tsconfig.json --onSuccess "node src/index.js" --compiler ./node_modules/.bin/tsc --onFailure "echo Compilation Failed"",
bind mount configuration:
volumes:
- type: bind
source: ./my-app/src
target: /home/node/src
tsconfig.json:
I am trying to use tsc-watch for hot reload during development, previously I used nodemon without issue. I migrated to TS and made configuration changes. tsc-watch is not working within the docker container. I change a .js file under source and compilation is not triggered. I am not sure if it is:
Please advise
The text was updated successfully, but these errors were encountered: