Replies: 9 comments 1 reply
-
You'll have to set NODE_OPTIONS in order for ts-node to auto-install into child processes. This is not currently something we do automatically, so it would be a feature request to add this. There's probably an issue for this; I recommend doing a search. Something like this will probably work for you: NODE_OPTIONS='--require ts-node/register' node ./bot.ts |
Beta Was this translation helpful? Give feedback.
-
thanks for the quick anwser. |
Beta Was this translation helpful? Give feedback.
-
Okay it works like a charm with the Node Options, and it also works with nodemon, thanks for your help again |
Beta Was this translation helpful? Give feedback.
-
I gonna report that fix to the dicord.js team, so that this gets more knowledgeable :) |
Beta Was this translation helpful? Give feedback.
-
Actually this node-option adds a new problem, that Types somehow don't get parsed the right way anymore, so You can't use this approach with |
Beta Was this translation helpful? Give feedback.
-
I bet setting TS_NODE_PROJECT and/or TS_NODE_FILES will fix that.
…On Thu, Apr 7, 2022, 6:00 AM Snoweuph ***@***.***> wrote:
Actually this node-option adds a new problem, that Types somehow don't get
parsed the right way anymore, so You can't use this approach with
"noImplicitAny"
set to true, because it will be missing all types
—
Reply to this email directly, view it on GitHub
<#1707 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC35OHE26VONQTSKS44FUDVD2W3DANCNFSM5SWOL3VA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I tried |
Beta Was this translation helpful? Give feedback.
-
or did you mean that I could just disable type checking fo dev only? |
Beta Was this translation helpful? Give feedback.
-
Disabling typechecking is IMO always the correct choice. We keep typechecking support for people who really want it, but I never use it. Run When using However, I suspect that if you add |
Beta Was this translation helpful? Give feedback.
-
Search Terms
Discord
Sharding
ChildProcess
SubProcecss
Expected Behavior
using ts-node (with nodemon or without it) to test without compiling every time, everything should just work fine without any errors that point that the config is set wrong.
Actual Behavior
when running Discord.js Sharding with ts-node it throughs errors that say that import cant be used outside of a module though inside of the tsconfig.json "moduleResolution" is set to "Node".
Steps to reproduce the problem
npm i -g typescript ts-node
npm i discord.js
ts-node bot.ts
this just works finets-node sharded.ts
this will now result with throwing errors that your not allowed to useimport
inside of the bot.tsconst manager = new discord.ShardingManager('./bot.ts', {
inside of the compiled sharded.js with './build/bot.js'node build/sharded.js
it works without problemsafter asking that problem on the official discord.js Discord Server and Github The answer I got was that this has nothing to do with discord.js and instead is a problem with ts-node in some way I also looked into the sourcedoe of discordjs but they are just using
node:child_process
andnode:worker_threads
package to achieve sharding. Other Libraries and Frameworks may also be affected by this.minimal reproduction
TypeStrong/ts-node-repros#27
Specifications
Beta Was this translation helpful? Give feedback.
All reactions