-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Cypress + Vite 5 + Typescript: exports is not defined in ES module scope #30313
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
Comments
You can try the suggestion from that issue and add the following directly to the top of "compilerOptions": {
"module": "ES2015"
}
{
"compilerOptions": {
"module": "ESNext"
},
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
} An alternative workaround is to rename |
Thank you very much, add module worked. Sorry for the repetition. |
It's good to hear that the configuration worked for you!
No problem! You should be able to close this issue now using the button below ⬇️ |
I don't believe this issue should be closed, as this issue indicates that cypress will not accept the TypeScript configuration from any tsconfig files unless they are named specifically Shouldn't it read the configuration from |
I agree with @iacullo-atri, adding |
This of course worked as well for me when adding to tsconfig.json (using vite) { So it seems like cypress is using ts-node and is only picking up the tsconfig in the root directory. (cause when I followed the cypress docs and added a tsconfig.json to the cypress folder, with compiler options, still get error) |
Current behavior
When I try to start cypress in a vite 5 project with typescript the console returns this error:

I think it is due to cypress having problems with the tsconfig.json structure created by vite.
I added cypress.config.ts inside include in tsconfig.app.josn, but even putting it in tsconfig.node.json the result does not change.
The 3 tsconfigs you will find I did not create, but are the basic vite react configuration (npm create vite@latest my-vue-app -- --template react-ts ). I just created the cypress setup with npx cypress open and, right away, the error appeared that referred to the cypress configuration.
Desired behavior
I would like to be able to run cypress in a newly created vite 5 project
Test code to reproduce
Repo
https://github.com/NormalCrazy000/vite5-Cypress.git
Steps to replicate
Cypress Version
13.15.0
Node version
18.19.1
Operating System
Windows
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered: