You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Module not found: Error: Can't resolve 'module' in 'node_modules/testdouble/lib' #531
I don't have any solutions here. But I might be able to point in the right direction. I assume you're running your tests in the browser via Karma? And that you're trying to use td.replaceEsm?
require('module') is breaking because it's trying to require the built-in Node.js module, probably because you're in a browser environment. From the replaceEsm docs, I think it pretty much relies on running within Node.js.
It'd be pretty easy to resolve that issue within can-register-loader.js by wrapping in a try/catch. But then you'll have other issues, since it looks like quibble (what testdouble.js uses for module mocking) also depends on core Node.js modules.
The short answer is that you'll probably be happier if you don't try to use replaceEsm in the browser. And probably only use replace to replace properties, not modules.
Activity
Michael-Ziluck commentedon Aug 29, 2024
Please fix this!
rosston commentedon Nov 2, 2024
I don't have any solutions here. But I might be able to point in the right direction. I assume you're running your tests in the browser via Karma? And that you're trying to use
td.replaceEsm?require('module')is breaking because it's trying to require the built-in Node.js module, probably because you're in a browser environment. From thereplaceEsmdocs, I think it pretty much relies on running within Node.js.It'd be pretty easy to resolve that issue within
can-register-loader.jsby wrapping in atry/catch. But then you'll have other issues, since it looks like quibble (whattestdouble.jsuses for module mocking) also depends on core Node.js modules.The short answer is that you'll probably be happier if you don't try to use
replaceEsmin the browser. And probably only usereplaceto replace properties, not modules.Fix webpack 5 browser builds
rosston commentedon Oct 12, 2026
Fixed in #548 and released in 4.0.0.