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

Cannot omit js extension when importing local module #8

Open
alebas1 opened this issue Jun 27, 2023 · 1 comment
Open

Cannot omit js extension when importing local module #8

alebas1 opened this issue Jun 27, 2023 · 1 comment

Comments

@alebas1
Copy link
Owner

alebas1 commented Jun 27, 2023

For example in: this line of code I am importing the health route using the js extension.

The result I would want is this: (omit the .js extension when importing a local file)

- import healthRoutes from './routes/health.js'
+ import healthRoutes from './routes/health'

I don't know how to do it yet.

@alebas1
Copy link
Owner Author

alebas1 commented Jun 27, 2023

When reading the docs, it seems to be the normal behavior for ESM

This might feel a bit cumbersome at first, but TypeScript tooling like auto-imports and path completion will typically just do this for you.

See https://www.typescriptlang.org/docs/handbook/esm-node.html
And nodejs/node#46006

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

1 participant