-
Notifications
You must be signed in to change notification settings - Fork 3.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
Scaffolded project with "tsc --init" + "type": "module" fails to compile due to conflicting module/commonjs #27359
Comments
I wonder what makes pnpm different to npm that breaks this? In fact, I wonder why a package manager has any bearing at all on this. All pnpm does is install packages, it shouldn't impact actual execution, right? Are we doing something deeply wrong -- we really shouldn't need package manager specific code at all. |
I changed it to |
This has nothing to do with pnpm, same result with |
If that's the case why doesn't https://github.com/cypress-io/cypress/tree/develop/system-tests/projects/config-with-ts-module-error catch it? |
Mr. @marktnoonan supposed that it was pnpm - apologies for not digging more. |
You can fix with {
"compilerOptions": {
"module": "ES2015"
}
} Explanation: #23552 (comment) Bit of a mess, this really should not be the experience users are greeted with. If you don't have a I'm not sure what the correct way to fix this would be - we probably don't want to clobber the default I am unsure why https://github.com/cypress-io/cypress/tree/develop/system-tests/projects/config-with-ts-module-error does not catch this. |
Ahhh I touched "target" when I did |
Should we close this? Or maybe pivot to "show a better error message"? Also the test project you linked is used... to assert the exact error you ran into is shown 😇
I wonder if the error should say something like "Check the |
Yeah I think "The module version in your tsconfig.json doesn't match the one in your package.json" is a good error message. |
I cleaned up stuff and expected behavior. Thanks again @lmiller1990 and @marktnoonan for triaging. I thought I was crazy. |
Ecosystem is the crazy one, especially the CJS + ESM mess. |
Actually, this happens outside of Cypress, too. We are just bubbling up what Node.js runs into.
So, I guess this is expected behavior? If we work around it, we'd be going against what would happen in a regular TS project. |
Current behavior
Desired behavior
Better error message. Something like the below
Test code to reproduce
Change package.json to use
"type": "module"
(the default fortsc
iscommonjs
)Cypress Version
Any >= 10. Currently 12.X
The text was updated successfully, but these errors were encountered: