-
-
Notifications
You must be signed in to change notification settings - Fork 2
Description
I am trying to write the equivalent of rails 'rake tasks' where I can write some typescript or javascript that is meant to be executed manually using node/ts-node via an npm script.
Here is the simplest example repo I could setup to reproduce the issue:
johncantrell97/blitzTask@2994c41
This commit adds tasks/example.ts which imports a util that logs a message to the console. If I import it as shown in the commit and try to run it using npm run example:task
I get the error Error: Cannot find module 'utils/exampleUtil'
If I update the import to be relative:
import exampleUtil from '../utils/exampleUtil'
it works fine.
This is a problem in my main project because all of my imports are using absolute paths from the baseDir defined in my tsconfig.json file. I'd prefer not to change all of them to relative imports for a few reasons.
ts-node supposedly uses tsconfig.json and can be manually passed in via --project flag as I have done in this commit. However, it does not appear to be respecting the baseDir for module resolution.
Any ideas how I can fix this?