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

import 6.0.1 TS project issue #409

Closed
deckikwok opened this issue Mar 27, 2023 · 7 comments
Closed

import 6.0.1 TS project issue #409

deckikwok opened this issue Mar 27, 2023 · 7 comments

Comments

@deckikwok
Copy link

Hi

imported "helmet": "^6.0.1" into express ts node project and faced the following error; Not sure why it would refer to the CJS module when I am using

import helmet from "helmet";

TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("helmet")' call instead.   To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field "type": "module" to ...

uploaded tsconfig
tsconfig copy.json.txt

thanks for taking a look

@EvanHahn
Copy link
Member

I've been working on fixes for this. Could you try this beta version to see if it works for you?

npm install "https://evanhahn.com/tape/helmet-6.0.1.tgz"

(See #405 for more details.)

@deckikwok
Copy link
Author

hi

that was fast

Sadly it didnt work for my tsconfig.

@EvanHahn
Copy link
Member

What happens if you use "module": "nodenext" in your tsconfig?

@deckikwok
Copy link
Author

hmm doesnt work too

@EvanHahn
Copy link
Member

It's a little hard for me to figure out what's going wrong. Could you create a sample project that reproduces the issue? It probably just has a package.json, a tsconfig.json, and an app.ts file.

@deckikwok
Copy link
Author

@EvanHahn
Copy link
Member

EvanHahn commented Mar 29, 2023 via email

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

No branches or pull requests

2 participants