moll / node-mitm

Intercept and mock outgoing Node.js network TCP connections and HTTP requests for testing. Intercepts and gives you a Net.Socket, Http.IncomingMessage and Http.ServerResponse to test and respond with. Super useful when testing code that hits remote servers.
Other
641 stars 48 forks source link

Module not found: Can't resolve '_http_server' #62

Closed eprince1 closed 2 years ago

eprince1 commented 5 years ago

The package fails to load and throws 'Module not found: Can't resolve '_http_server' in 'C:\Users\eitan\Documents\Github\my-app\node_modules\packagetest\node_modules\mitm'.

Not really sure whats going on.

moll commented 5 years ago

Hey! Could this be with Node v13?

moll commented 5 years ago

Then again, Node v13 seems to work on Travis CI (https://travis-ci.org/moll/node-mitm/jobs/604611743)...

eprince1 commented 5 years ago

updated my node to v13. Still having the issue tho...

react-dom.development.js:25810 ./node_modules/mitm/index.js

Module not found: Can't resolve '_http_server' in 'C:\Users\eitan\Documents\Github\pokemon\node_modules\mitm'

eprince1 commented 5 years ago

have the same error for _http_incoming and _http_common

moll commented 5 years ago

I'm seeing "React-DOM development" above in your stack trace. How are you running Node? React is a front-end library, but Mitm.js is only for the Node backend...

moll commented 5 years ago

Did you solve the problem? What was the cause?

obenshaindw commented 2 years ago

@moll we are trying to use failure-lambda which depends on mitm, and we are getting the same error reported here.

ERROR in ./node_modules/mitm/index.js 37:24-65 Module not found: Error: Can't resolve '_http_incoming' in '...node_modules/mitm'

ERROR in ./node_modules/mitm/index.js 38:23-61 Module not found: Error: Can't resolve '_http_server' in '...node_modules/mitm'

ERROR in ./node_modules/mitm/index.js 39:27-67 Module not found: Error: Can't resolve '_http_common' in '...node_modules/mitm'

moll commented 2 years ago

Hey,

What Node.js version is this with and if you run node directly and try to require the _http_common module, does that work?

obenshaindw commented 2 years ago

@moll, following several GitHub threads related to errors with importing these requirements in other projects the culprit seems to be with webpack, which we are using to bundle code for our AWS Lambda functions (that now include failure-lambda... mitm as a dependency).

Using webpack.config.js and specifying external dependencies to include ['_http_common', '_http_incoming', '_http_server'] seems to resolve our problem with building the lambda functions.

https://www.npmjs.com/package/webpack-node-externals

I will report back if this succeeds.

moll commented 2 years ago

Good to know. Thanks for sharing. I'll close the issue for now, but do report back once you've solved it for good!