ts-node-dev: Package is broken with node 14 : fs.watch with recursive is throwing on incompatible os
Hello,
I just upgraded node to v14 on my fedora 31. It seems this package is now broken due to this commit : https://github.com/nodejs/node/commit/67e067eb06
Also check updated doc : fs.watch doc
The recursive option is only supported on macOS and Windows. An ERR_FEATURE_UNAVAILABLE_ON_PLATFORM exception will be thrown when the option is used on a platform that does not support it.
Output error example :
# npx ts-node-dev src/main.ts
Using ts-node version 8.4.1, typescript version 3.8.3
TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
at Object.watch (fs.js:1441:11)
at add (/root/backend/node_modules/filewatcher/index.js:74:34)
at /root/backend/node_modules/filewatcher/index.js:93:5
at FSReqCallback.oncomplete (fs.js:176:5)
Using recursive: true now throws an Error that is not handled. https://github.com/whitecolor/ts-node-dev/blob/c0df64c43455d2f8ef144eb9defcd05b6fc52486/lib/index.js#L45
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 54
- Comments: 21 (2 by maintainers)
Commits related to this issue
- Lowering NodeJS version until ts-node-dev fixes a bug https://github.com/whitecolor/ts-node-dev/issues/143 — committed to JVictorV/orangedit by JVictorV 4 years ago
- kludge fix issue #143 — committed to mmvsk/ts-node-dev by deleted user 4 years ago
- Upgrade node to v14 Update webapp babel (via manual lockfile deletion & reinstall) due to https://github.com/babel/babel/issues/11216 Update webapp node-sass for Node 14 support Update webapp element-... — committed to metaspace2020/metaspace by LachlanStuart 4 years ago
- Upgrade to Node 14 (#637) * Upgrade node to v14 Update webapp babel (via manual lockfile deletion & reinstall) due to https://github.com/babel/babel/issues/11216 Update webapp node-sass for Node 14... — committed to metaspace2020/metaspace by LachlanStuart 4 years ago
Will check everything and release it with chokidar soon.
Run using
ts-node-dev --poll src/index.ts
Hey, while waiting for a fix in
filewatcher
or here, I just made a quick & dirty fix by disabling therecursive
option on Linux and Node 14, to be able to usets-node-dev
right now in this environment.To select this specific commit:
npm add -D 'mmvsk/ts-node-dev#d7e9cfbad414bcc5fc9ddb5cf75a74496a9e4549'
Replaced with
chokidar
in the latest published.Bump - just updated to node v14 and got the same issue. Downgrading to v13 or lower works just fine. (I recommend using https://github.com/tj/n or https://github.com/nvm-sh/nvm)
Edit: It seems like
ts-node
had a similar issue a while ago? https://github.com/nodejs/node/issues/20258Yes, it’s precisely what it does. But actually the recursive option never worked on Linux: before Node 14
fs-watch
was silently failing, and now it raise an error. So this PR is basically revertingts-node-dev
to its original behavior.Actually it “works” on Linux in the same way it was working before Node 14: by using the dependency chain built by the imports. So it’s possible to have some missed detections if a file is modified in a deep directory without being imported anywhere - in the exact same way as in Node 13 and before - but in most cases it will work just fine.
And I agree with you: ideally,
fs-watch
should be replaced andnode-watch
seems like a good candidate for that, better thanchokidar
that was proposed earlier in this thread.tl;dr
fs-watch
should be replaced by a better alternative (such asnode-watch
)@ssomlk you should
node:13-alpine
if you want to use Node 13 instead of latest.Here you can find a list of all the released tags: https://hub.docker.com/_/node/ I think that Docker has a Get Started guide that may help you with these basic concepts.
Problem is in underlying
filewatcher
issue is already raised in there and PR madeThnx for @onlurking for making fix for it
But it seems like filewatcher has not been updated for a while tho, so not sure if it will get merged in there 😞
@whitecolor I think we can fix this issue by migrating to chokidar instead of fs.watch. Does it make sense?