You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also if you don't want to install ts-node globally:
#!/usr/bin/env -S node -r "ts-node/register"
Reacted by Stian Liknes, Avinash Dwarapu, Glenn 'devalias' Grant, Jamie, Adrien Crivelli, Vsevo1od, Micael Levi L. Cavalcante, Tolga Paksoy, Benoit V., David Nunez and 7 more
Reacted by Max Komarychev, Lorenzo, Jamie, Zack, Sean Herman, Micael Levi L. Cavalcante, Victor Moraes, Wlad Paiva, Eric Haynes, Peter McIntyre and 2 more
Ahh. I see. I need to use ts-node-script. So in an Nx project, if I'm making a publishable lib, it creates 2-3 tsconfig files. Obviously, when it is published node would run the CLI, but for testing purposes, I was thinking it would be nice to run it with ts-node from inside the same mono-repo... It might not pick up the tsconfig.lib.json, but it should pick up the tsconfig.json and if that isn't good enough, I can probably just build it before using it in mono-repo.
Yeah, we also let you override some "compilerOptions" within a tsconfig's
`"ts-node": {}` object. So you can tell the compiler to behave differently
in ts-node if needed. I think this is in the readme too, but if you find
the readme is insufficient, feel free to file a ticket so we can improve it.
On Sun, Jun 28, 2020, 5:33 PM Troy ***@***.***> wrote:
Ahh. I see. I need to use ts-node-script. So in an Nx project, if I'm
making a publishable lib, it creates 2-3 tsconfig files. Obviously, when it
is published node would run the CLI, but for testing purposes, I was
thinking it would be nice to run it with ts-node from inside the same
mono-repo... It might not pick up the tsconfig.lib.json, but it sounds pick
up the tsconfig.json and if that isn't good enough, I can probably just
build it before using it in mono-repo.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#73 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC35OHUSAKJ3HZMESZLU63RY6ZJZANCNFSM4B5ZUA3A>
.
as does #!/bin/ts-node which is closer to #!/bin/bash, but I would stick with the above, since is more common and others are less likely having to adapt it.
nb1: I am aware, that /bin ist just a link to /usr/bin probably on most linuxes, just a cosmetic choice where to link to.)
nb2: If someone works with ts-node under a different account on your machine, he might encounter rights issues from this linking into a personal folder. Unless you are suffently generous with chmod on your ~/.npm-global.
I am not using nvm (figured out it cost me 2-3 seconds whenever opening a new terminal tab.), plain node 18.x
Activity
blakeembrey commentedon Mar 13, 2016
@nevir Works for me, what's your issue?
blakeembrey commentedon Mar 17, 2016
Closing as it appears to work.
blakeembrey commentedon Mar 23, 2017
It works but you will need the
.tsextension. See #116.b1zzu commentedon Oct 7, 2019
Also if you don't want to install ts-node globally:
ORESoftware commentedon Oct 7, 2019
without the ts extension, I assume you could do something like
VanTanev commentedon Feb 9, 2020
A bit more complete version of @ORESoftware's example above:
troywweber7 commentedon Jun 28, 2020
What's the best way to add the project flag to the shebang?
cspotcode commentedon Jun 28, 2020
troywweber7 commentedon Jun 28, 2020
Ahh. I see. I need to use ts-node-script. So in an Nx project, if I'm making a publishable lib, it creates 2-3 tsconfig files. Obviously, when it is published node would run the CLI, but for testing purposes, I was thinking it would be nice to run it with ts-node from inside the same mono-repo... It might not pick up the tsconfig.lib.json, but it should pick up the tsconfig.json and if that isn't good enough, I can probably just build it before using it in mono-repo.
cspotcode commentedon Jun 28, 2020
micalevisk commentedon Mar 4, 2022
another one
tsconfig-pathsnpx(so you don't need to install ts-node globally)tsconfig.jsonfilecspotcode commentedon Mar 5, 2022
You can also move the
transpileOnly,files, and-rinto yoursrc/tsconfig.json, which simplifies the shebang to:If the script is already within the
./src/directory, then you can even omit-p.nocke commentedon Sep 3, 2022
I had luck with
sudo ln -sf ~/.npm-global/bin/ts-node /bin/ts-nodethereafter
#!/bin/env ts-nodeworks.#!/bin/ts-nodewhich is closer to#!/bin/bash, but I would stick with the above, since is more common and others are less likely having to adapt it./binist just a link to/usr/binprobably on most linuxes, just a cosmetic choice where to link to.)ts-nodeunder a different account on your machine, he might encounter rights issues from this linking into a personal folder. Unless you are suffently generous withchmodon your~/.npm-global.