Skip to content
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: Cannot find module '../crypto/util' #514

Open
tpluscode opened this issue May 4, 2023 · 5 comments
Open

Error: Cannot find module '../crypto/util' #514

tpluscode opened this issue May 4, 2023 · 5 comments

Comments

@tpluscode
Copy link

tpluscode commented May 4, 2023

In a mocha test I use readable-stream and I got this

Error: Cannot find module '../crypto/util'
Require stack:
- packages/formats/node_modules/readable-stream/lib/internal/streams/lazy_transform.js

I did not find why it gets loaded but the fact is there is no crypto/util.js or similar module.

@mcollina
Copy link
Member

mcollina commented May 4, 2023

how do you load lazy_transform.js?

@tpluscode
Copy link
Author

That's kinda the thing, I don't.

There are only 2 mentions of lazy_transform in my entire working directory

> find . -type f | xargs egrep -i lazy_transform
node_modules/watchpack-chokidar2/node_modules/fsevents/build/config.gypi:      "lib/internal/streams/lazy_transform.js",
node_modules/webpack-dev-server/node_modules/fsevents/build/config.gypi:      "lib/internal/streams/lazy_transform.js",

@tpluscode
Copy link
Author

Any ideas? For now I patched this locally but again, why is that module trying to import ../crypto/util.js which does not exist?

@kanongil
Copy link

The main issue seems to be that readable-stream includes a broken-on-require unused internal module (lazy_transform).

This is a problem since bundlers / transpilers / test runners can sometimes recursively load all **.js modules, as is likely happening here.

@mcollina
Copy link
Member

lazy_transform should be skipped when we build this module from Node.js core source.

Adding it to this list would do: https://github.com/nodejs/readable-stream/blob/main/build/files.mjs

Would you like to send a PR? Ideally it should contain a unit test for this issue so we do not regress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants