cypress: webpack-preprocessor cleanError throws TypeError
TypeError: err.replace is not a function
It seems err is an Error in my case, not a string.
I’m not familiar enough to make sure it would break anything else, but changing the js output locally to err.message.replacefixes things for me.
My real error was:
"Module not found: Error: Can't resolve '../../src/Component' in '<mypath>/cypress/component'"
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 29
- Comments: 51 (5 by maintainers)
Commits related to this issue
- Upgrade @cypress/webpack-preprocessor and move dev deps to devDeps Started getting a cryptic `TypeError: err.replace is not a function` error when trying to run cypress tests locally. As per suggest... — committed to newsrevenuehub/rev-engine by deleted user 2 years ago
- Upgrade @cypress/webpack-preprocessor and move dev deps to devDeps Started getting a cryptic `TypeError: err.replace is not a function` error when trying to run cypress tests locally. As per suggest... — committed to newsrevenuehub/rev-engine by deleted user 2 years ago
Getting issue with Cypress 9.0 now, with a new installation
Opened https://github.com/nrwl/nx/issues/5906 for nrwl/nx users, as I couldn’t find a way to replace
cypress-webpack-preprocessorwithcypress-webpack-preprocessor-v5there.actually I realise now I’ve edited this file directly in my node_modules folder:
node_modules/@cypress/webpack-preprocessor/dist.index.js Adding line - console.log('err = ', err); // add this line
Now running cypress I can see the typescript errors I need to fix. thankyou
Cypress webpack-preprocessor does not yet support Webpack 5 as explained in this issue: https://github.com/cypress-io/cypress/issues/8900
We released a temporary version of this package that supports webpack v5 – npmjs.com/package/cypress-webpack-preprocessor-v5
Is anyone getting this error outside of using Webpack 5? Because we will close this issue if not as it’s a duplicate of https://github.com/cypress-io/cypress/issues/8900
Hi, using the cypress-webpack-preprocessor-v5 fixes the issue for me.
There is no problems with webpack@4.44.2
Please prefer thumbing up the issue over posting “+1” comments (each one of them sends unnecessary email notifications). Thanks
using
nvm install 16.13.0fixed the issueseems was an issue with using node 17
The underlying problem here seems to be that the webpack instance started by cypress is using a flawed
require.resolvealgorithm. You can usecypress-webpack-preprocessor-v5to fix theerr.replaceerror, but the underlying issue remains where the modules required by webpack dependencies are not using the normal node resolution algorithm.In my case, babel-loader throws an error
validateOptions is not a functionbecause it is resolving the wrong version ofschema-utils. I added some logs to the top ofnode_modules/babel-loader/lib/index.jsto prove this:I’ve also seen this same issue manifest with different versions of
enhanced-resolveinstalled innode_modules/webpack/node_modules/enhanced-resolveandnode_modules/enhanced-resolve. I would not be surprised if there are other variations of the same issue.Any updates on this ?
@rkrisztian my code is already part of the package, even the double
\n🤣While we’re waiting for a fix, we can use patch-package with @mhamri’s code line changes, to alleviate the problem a bit (just in case you didn’t know).
Edit: I am too late with this, due to more recent releases of @cypress/webpack-preprocessor.
for god sake fix it, it’s as easy as this, this error is there since version 4
and it will shows the error correctly
✨ This is an old work account. Please reference @brandonchinn178 for all future communication ✨
I had this problem and found out the problem was my Cypress tests written in Typescript had type errors.
How I figured this out is by adding
console.log(err)before theerr.replaceline, which output:This is rather annoying, and it’d be great to get this fixed. It seems like it’s mostly a matter of changing
to