Closed tslocke closed 2 years ago
What version of node/npm/jest are you using?
main
is only for legacy versions of node.
https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
Jest 27.5.1, Node 16.14.2, npm 8.5.0
Weird. I have no idea why I'm getting this error then. Lots of other imports with no problem.
Could the target/module settings in tsconfig be relevant? I have:
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
Those versions all look good. Let me try...
https://gist.github.com/arv/0a3f7b5c0b831f15b5eaaea7a5e5a725
I don't have "type": "module"
in my package.json. Is that the issue?
If I add it, I get errors loading jest.config.js and babel.config.js
You appear to be using a native ECMAScript module configuration file, which is only supported when running Babel asynchronously.
If you add "type": "module"
you probably need to rename some of your config files to ".cjs".
Is there a downside to accepting the PR? Maybe there is, but if not it seems like it could be helpful for people stuck between the two module systems like I seem to be.
No downside. Just trying to understand.
Was unable to import this as a module in a Jest environment without this.