Skip to content
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

Document needing ts-node #740

Closed
zkldi opened this issue Apr 14, 2021 · 4 comments
Closed

Document needing ts-node #740

zkldi opened this issue Apr 14, 2021 · 4 comments

Comments

@zkldi
Copy link
Contributor

zkldi commented Apr 14, 2021

Perhaps I'm missing something obvious - as of v15 I cannot get module-based typescript to work.

Running with the TS flag set and typescript installed, I get

SyntaxError: Cannot use import statement outside a module

Enabling `"type": "module" in package.json results in

Can't run my Node.js Typescript project TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension “.ts” for (file)

And according to SO, the fix for that is to remove "type": "module". This happens regardless of what tsconfig's opinions on the output of TS is (I have it set to CommonJS, but it doesn't change anything).

@zkldi zkldi changed the title No longer works with module-based TypeScript Document needing ts-node Apr 14, 2021
@zkldi
Copy link
Contributor Author

zkldi commented Apr 14, 2021

Update: This can be fixed by manually installing ts-node (similar to how you have to now manually install typescript), but this is not documented anywhere. Can submit a pull request to add this to the docs in a bit.

A warning should possibly be emitted if the TS flag is set but ts-node is not present, as at the moment it silently defaults to JS loading.

@StarpTech
Copy link

@zkldi thank you! Complete solution is:

  1. Install typescript, ts-node, @types/tap
  2. Run tap --ts

There is a typo in the docs it's --ts not -ts.

zkldi pushed a commit to zkldi/node-tap that referenced this issue Apr 19, 2021
@zkldi
Copy link
Contributor Author

zkldi commented Apr 19, 2021

PR in #744

isaacs pushed a commit to zkldi/node-tap that referenced this issue Apr 29, 2021
PR-URL: tapjs#744
Credit: @zkldi
Close: tapjs#744
Reviewed-by: @isaacs
@zkldi
Copy link
Contributor Author

zkldi commented May 12, 2021

Closed as #744 got merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants