-
Notifications
You must be signed in to change notification settings - Fork 121
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
paths option(tsconfig.json) is ignored #95
Comments
WorkaroundHere is a workaround for folks with the same problem. Install concurrently (or another preferred alternative) and node-dev (or maybe another like nodemon). npm uninstall ts-node-dev
npm install concurrently node-dev --save-dev Then run concurrently 'tsc -w' 'node-dev --respawn dist/index.js' This would incrementally compile editted .ts files( |
This is strange "workaround" =) Should this even work with node.js without special plugins? TS compiler doesn't transform require paths like '#/foo', so it should just give the error There is a module https://github.com/dividab/tsconfig-paths allows to handle tsconfig's paths option with node.js |
Thank you for the recommendation :)
The compiler doesn't transform but compiles it "as-is"
For example, I set a symlink So, I let ts compiler check types by looking "paths", and node find modules by symlinks. Maybe you can read https://dev.to/larswaechter/path-aliases-with-typescript-in-nodejs-4353 if you want. What I suggest is, of course, different from Sometimes, project structure gets deeper and wider, so using absolute path provides significant benefit. If ts-node-dev doesn't care them, people using aliases have to find other ways like the "workaround" I suggested. And what we should consider is, people negatively feel to fragmented setting. They prefer setting as consistent as possible through projects, no matter big or small. If ts-node-dev doesn't support, then they might just avoid using it at all even on projects without aliases. P.S.
"strange"..? Hmm, why? pros
cons
It works smoothly. jjangga0214/ts-boilerplate is a working example. You can clone it, run |
If you ok with this *.js filles all around while dev, it is just another approach. Also I prefer to use |
@whitecolor Thanks for the recommendation again. |
This is a task for another package, as I said you may use https://github.com/dividab/tsconfig-paths to achieve that if needed, setup is quite transparent. |
Closing this issue. Thanks for the suggestion anyway :) |
If anyone has issues with this, try the module-alias plugin. So far it's the cleanest solution I've found and it is working all right! Given a directory structure like the following:
Create a
Then, in the
Finally, set
|
@whitecolor I would recommend to add a note about this (also mentioning Because while I love |
@whitecolor tsconfig paths does not seem to work with Running via My aliased paths do not resolve. |
Not sure why it may not work, when I used it, it worked ok. |
Please disregard. I was a bit confused when running a |
For anyone finding this and want a two-liner here it is: then in your package.json add a script like this: |
It doesn't work for me, but I have a -P path/to/tsconfig.json as well.. It might be throwing things off? Edit: It works with ts-node but not with ts-node-dev .. Edit Edit: got it working with cross-env TS_NODE_PROJECT='./src/some/folder/tsconfig.json' ts-node-dev ... |
Thanks @microcipcip for directing me to module-alias plugin, since the other comments e.g I created a
Then, in the
Inside my
I have a
|
And ignored |
my original answer to fix ts-node paths problem here: TypeStrong/ts-node#138 if ts-node-dev also support to read "ts-node" configuration on tsconfig.json, i think it may help |
Thanks @soupman99 it works like charm |
Settings
tsconfig.json
Other options are omiited for brevity.
command
src/index.ts
Problem
When I edit foo.ts, which index.ts depends on, ts-node-dev does not respawn. I guess it's because ts-node-dev does not consider the paths option in tsconfig.json.
The text was updated successfully, but these errors were encountered: