-
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
Error [ERR_REQUIRE_ESM]: require() of ES Module during Cypress upgrade to the v10.0.1 #22038
Comments
Are you able to share your existing project? Ideally a repo we could clone, but if that's too much trouble, a If you could re-run the migration with It looks like it's incorrectly generating a ES modules based config; if you just want to make it work, you could change to using CJS: const { defineConfig } = require('cypress')
module.exports = defineConfig({
// your config content here, as generated by the migration tool
}) If you could share a slimmed down version of the repo you want to migrate, that'd be great - we can work through it and find out what's going wrong, so others can have a smooth migration process. |
For anyone at Cypress looking into this: We generate ES module based In this case, it's generating a The original issue says that they tried adding |
I see an identical issue, not during any upgrade, just starting from scratch with Cypress 10.0.1. I am using Node.js 18.2.0 and npm 8.9.0. On Windows, obviously, and using Git Bash for Windows. My minimal reproduction is as follows.
{
"name": "what",
"version": "1.0.0",
"type": "module",
"devDependencies": {
"cypress": "^10.0.1"
}
}
import { defineConfig } from 'cypress'
export default defineConfig({}) npm install
npx cypress run
Note that here in your code:
there is an error which is being discarded. I've found that the text of that error is:
In my case, the filename in question is |
I have same problem too |
@qntm Thanks for all the info here - this is all really helpful in helping us track down what's going on. @woytekn Wanted to confirm something - in your first project, when you ran the migration, before you added
You probably don't want to change to
|
The code for this is done in cypress-io/cypress#22042, but has yet to be released. |
…hub.com:cypress-io/cypress into tgriesser/fix/change-typescript-detection-rules * 'tgriesser/fix/change-typescript-detection-rules' of github.com:cypress-io/cypress: fix: do not watch specs on run mode (#22060) fix: #22038 support esm import for windows (#22042) fix: Change ffmpeg to post process at priority 20 (#21587)
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior
When I try to upgrade Cypress to v10.0.1 I get "SyntaxError: Cannot use import statement outside a module"
I've read that the solution for this issue is adding
"type": "module"
in package.json but now I am getting another issue:[Stack trace](http://localhost:55743/__launchpad/index.html#) Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/xxx/Documents/Cypress/my_project/cypress.config.js from /Users/xxx/Library/Caches/Cypress/10.0.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js not supported. Instead change the require of cypress.config.js in /Users/xxx/Library/Caches/Cypress/10.0.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js to a dynamic import() which is available in all CommonJS modules. at loadFile (/Users/xxx/Library/Caches/Cypress/10.0.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:103:14) at EventEmitter. (/Users/xxxLibrary/Caches/Cypress/10.0.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:146:38) at EventEmitter.emit (node:events:527:28) at EventEmitter.emit (node:domain:475:12) at process. (/Users/xxxLibrary/Caches/Cypress/10.0.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22) at process.emit (node:events:527:28) at process.emit (node:domain:475:12)
Do you have any ideas on how to solve it?
Cypress Version
10.0.1
Package Manager
npm
Operating system
Mac
Other
No response
The text was updated successfully, but these errors were encountered: