-
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]: Must use import to load ES Module error thrown #8090
Comments
I'm not seeing this code running properly in 4.5.0 either. Can you include the code that was properly running in 4.5.0? The code you're trying to update? |
Thanks for replying, import webpack from '@cypress/webpack-preprocessor/index.js';
const plugins = async (on, config) => {
// we import dynamically webpack.config for diff projects
const webpackOptions = (await import(path.resolve(`projects/${PROJECT}/cypress/webpack.config.js`))).default;
on('file:preprocessor', webpack({webpackOptions}));
};
export default plugins; I run also cypress normal with "@cypress/webpack-preprocessor": "4.1.3",
"cypress": "4.5.0", node version: 14.4.0 Is the error that you're getting is the same as I described? |
@jennifer-shehane I found the issue, the moment I have typescript installed with the following configuration the error will occur: // tsconfig.json
{
"compilerOptions": {
"allowJs": true
}
} I also tried to alter the working on creating a repo to reproduce |
and here is the repo https://github.com/nitzanashi/cypress-typescript-issue |
I can reproduce this from the provided repo, but I'm still not seeing this issue being introduced in 4.6.0. The same error occurs for me in 4.5.0 and even back to 3.8.1.
Regardless, this error does not appear in our upcoming 5.0.0 release, a different error displays in its place.
It's failing on the resolve here. import webpack from '@cypress/webpack-preprocessor/dist/index.js';
import path from "path";
const plugins = async (on, config) => {
const webpackConfig = (await import(path.resolve('cypress/webpack.config.js'))).default;
on('file:preprocessor', webpack({webpackOptions: webpackConfig()}));
}
export default plugins; There's also this warning in the console:
|
@jennifer-shehane indeed the code in the repo didn't work for 4.5.0 as well, I fixed it by adding
I updated the repo, so now if you will check it, it will work for 4.5.0 I tested it also on 5.0.0 but errors are still there |
Any suggestion on how to solve this? how can I change my code so it will work? |
looks like it was fixed in #8359 and released in 5.1.0 well not quite, it doesn't identify my commands now, need to investigate more |
OK so adding I still can't update from 4.5.0, it's a bummer :/ |
@jennifer-shehane any update on that? our project is currently running on Cypress 4.5.0 because of this issue and we would like to update to use the latest features |
If someone have this issue as well, we found a hack on how to solve it by adding |
Still a problem today with a new Svelte Kit skeleton project! |
For now I have fixed the issue by adding {"pluginsFile": false} to the cypress.json file. I suppose this only works if you don't need plugins though. |
What worked for me was to remove "type": "module" from my package.json (as stated in the error message) |
That doesn't work for many projects where you explicitly need imports to be es6 modules. |
@Shaun-Regenbaum did you try to run Cypress with my kludge?
|
I did not, ill give that a try later. |
Hi, today I tried cypress for the first time. Just to confirm, after apt install command, with a fresh npm install on debian buster, the same error reported in this issue returns for me. Tried on MacOS 10.15.7, exactly same error after following post-install node_modules/.bin/cypress open. I now assume this issue can be reproduced with a simple fresh install. Project uses ES Modules. So I edited cypress.json from {} to {"pluginsFile":false} as noted in error. Then it runs as advertised. |
I'm also trying to get Cypress to load with "type": "module"? Removing "type": "module" is not a solution and setting pluginsFile to false removes usage of plugins. |
Update, today I installed Cypress again, using npm install cypress --save-dev, and it pulled version 8.3.1, This issues's error remains as reported on fresh install. |
Any updates on this? I'm facing this issue as well now. After adding |
This appears to still be an issue; latest Cypress tries to |
For me it worked to rename the plugins index to index.cjs and specify it in cypress.json:
|
That does not work with at least
|
@talaikis could it be that the file |
To get it running I had to change the plugins file to I'm running this in a Sveltekit project and IIUC the cause is the edit: you can also use a hack that works to get Storybook running: instead of renaming to index.cjs you can add a package.json file to /cypress that contains:
But I still need to use |
Maybe this could be a good minimal repro to investigate the issue, as it only requires the import of clipboardy in a plugin file? |
Still got some error.
I bootstrapped my app with sveltekit. |
This is what worked for me. |
This worked. |
None of this, except removing What did work for me, however, was upgrading from Cypress |
Current behavior:
We're trying to update Cypress from 4.5.0 to >= 4.6.0 but we encountered into a problem
My setup is a little bit different from the usual one, I have a index.cjs and index.js, cypress.json config is as follow:
plugins/index.cjs
plugins/index.js
package.json as
"type": "module",
but I do not understand why cypress should care about it.Furthermore I tried to update
@cypress/webpack-preprocessor
from4.1.3
->5.4.0
with modification toindex.js
but no changes.I'm not sure if it's a cypress issue or cypress/webpack-preprocessor issue but it's a blocker for me to update cypress
Desired behavior:
Cypress is loaded as expected and working
Versions
>= 4.6.0
The text was updated successfully, but these errors were encountered: