-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
[Bug] Problem with running via ts-node when entry file is in a different directory #181
Comments
I can also mention, I've tried replacing this library to I pushed a branch to show that it works using |
Thanks for the report!
Have you tried specifying the tsconfig file when running the command? I will take a look at the repro when I'm able, if that doesn't work. Just thought I'd send a quick reply first. |
Hi. I tried your suggestion of manually setting the tsconfig file for each project (i.e. But I dug some more and did some additional testing, and I think it has something to do with how For pack-a:
For pack-a:
Notice that the only difference between the two is the From this find, I tried to manipulate So in the end, I am not entirely sure if the problem is with this library or if it is with |
If I try to run a project using
ts-node
, and the entry file the ts-node command points to is in a different directory from your current working directory, then the path remapping won't be correct. If you build the project however, then the path mapping will be correct. It might be that I configure something wrong along the way, but I can't really figure out what that would be in that case.I've set up an example project you can clone that shows the issue: https://github.com/Gikkman/typescript-transform-paths-reproduce-ts-node-problem
Clone the project, then run
npm i
to set everything up. Runningnpm run dev:a
will try to runts-node
in a way that crashes, but runningnpm run dev:b
will run it in a way so it works. You can then build the project, usingnpm run build
. If you inspect the output (under thebuild
folder), you'll see that the build output has correct mappings. Running the built projects vianpm run start:a
ornpm run start:b
will also show that both works post-build.If I were to theorize, I'm guessing the first file's path resolution doesn't take into consideration that it might not be in the same directory as script is invoked from. It isn't hard to work around IMO (just make a bootstrap script in the same directory as the package.json) but I thought it might be worth mentioning.
The text was updated successfully, but these errors were encountered: