-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
OpenTelemetry with NodeJs and Typescript #4812
Comments
Thanks @g1nsu @open-telemetry/javascript-approvers can you take a look? |
Hi @g1nsu, You are right that the TypeScript option in the current docs is assuming that I agree that mentioning using
|
Hi @trentm, It looks like I missed the assumption that the code was compiled to CommonJS since the TypeScript command still shows I think your proposed changes look great. I just thought I could save someone else a few minutes. Thanks! |
I'm pretty sure it isn't explicitly stated anywhere. |
@g1nsu would you be interested to update the documentation accordingly? Could be a simple note that people might run into that and what to do in that situation |
@svrnm Yes, I can certainly update the documentation. Should I just check out the Contributing documention and make a PR? |
Thanks, that would be great! Yes, please give them a look! Especially pay attention to the CLA that we have to ask you to sign (except you have contributed to any other CNCF/LF project already). I call this out because this is a blocker for people sometimes. |
After some more testing, the documentation does work as written using ts-node. Running with ts-node only works when the tsconfig has set The issue I encountered has to do with tsx. The tsx package only works with the If you would still like a documentation note, I can do so. But since this is a tsx specific detail, we can close this as resolved. |
When setting up NodeJs with Typescript, the documentation suggests using the --require flag. However, I received an error ("Cannot use import statement outside of a module.") when taking this approach.
When I reviewed the NodeJs documentation for the --require flag from the link in the OpenTelemetry page, it suggested using the --import flag for ECMA modules. Once I made this change, everything started working. I must also note that I am using tsx to run the project.
Mentioning the --import flag may help some users when setting up OpenTelemetry for the first time.
The text was updated successfully, but these errors were encountered: