Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module 'tsconfig-paths/register'

I'm trying to run a typescript script with ts-node in CLI, which means I don't have a package.json.

Here's the command I'm trying to run:

npx -p typescript@latest -p ts-node@latest -p @types/node@latest ts-node -T --project scripts/tsconfig.script.json scripts/my-script.ts

It works perfectly fine when I use relative paths inside the script.

Then I'm trying to enhance it by enabling paths from tsconfig.script.json in order to be able to import from them.

I want to use tsconfig-paths for it. Here're the command I'm trying to run:

npx -p typescript@latest -p ts-node@latest -p @types/node@latest -p tsconfig-paths@latest ts-node -T -r tsconfig-paths/register --project scripts/tsconfig.script.json scripts/my-script.ts

However, I'm getting the following error:

Error: Cannot find module 'tsconfig-paths/register'

I've tried to play around with order of arguments of ts-node as well as adding/removing options, however, I still cannot make it work and see the tsconfig-paths package.

Am I missing smth?

Thanks in advance

like image 441
Michael Khaliavski Avatar asked Dec 17 '25 08:12

Michael Khaliavski


1 Answers

I ran npm install --save-dev tsconfig-paths and that error went away.

like image 152
Carl Walsh Avatar answered Dec 20 '25 00:12

Carl Walsh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!