-
Notifications
You must be signed in to change notification settings - Fork 68
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
Can't use typescript commands with ESM modules #421
Comments
@davidthor thanks for posting the issue - I'm looking into it now |
Check this response... Looks like you need to use ts-node in the shebang of the run script. I haven't tried this myself, so no idea on how it will work w/ a mixed CLI project offhand. Worth a shot though.
|
@typhonrt Thanks for the comment - that was the last piece of the puzzle I needed to solve this. Using the ts-node shebang works but we still need to support directory imports for typescript projects, which I made a PR for: #422 @davidthor Once that PR is merged you'll need to ensure that you have the following in your project:
|
Funnily enough I had tried everything done in the PR and your comment EXCEPT this addition to the tsconfig. That did the trick! Thanks! ---- Edit ---- In case anyone finds this later, I was having trouble with relative module imports even after adding this. What worked for me is changing the #!/usr/bin/env node --loader ts-node/esm --experimental-specifier-resolution=node The |
@davidthor Thanks a million for coming back with that edit. Been struggling with Relative Imports all day getting this error:
Adding your shebang modifiers got everything working! |
Hi there,
I'm trying to create an oclif CLI as an ESM package that uses typescript, but am having trouble with using commands with the
.ts
extension. The CLI works fine if my command files are.js
files, but the minute I rename them to.ts
I get the following error:I tried digging around in the module-loader doing things like adding the
.ts
extension tos_EXTENSIONS
and theisPathModule()
method, but only seem to be digging a deeper hole. Does anyone have an example of how this is expected to work?Source
./bin/dev.js
package.json
./src/commands/create/index.ts
The text was updated successfully, but these errors were encountered: