nodejs / readable-stream

Node-core streams for userland
https://nodejs.org/api/stream.html
Other
1.03k stars 228 forks source link

error: Error: Unable to resolve module ../../../../../src/util from node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_readable.js: #535

Open justankit opened 7 months ago

justankit commented 7 months ago

Hi,

Please help me to fix this error. This dependency is being used as a sub-dependency of react-native-crypto.

error: Error: Unable to resolve module ../../../../../src/util from node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_readable.js:

None of these files exist:

src/util(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx) src/util/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx) 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the at ModuleResolver.resolveDependency (node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:136:15) at DependencyGraph.resolveDependency (node_modules/metro/src/node-haste/DependencyGraph.js:231:43) at Object.resolve (node_modules/metro/src/lib/transformHelpers.js:129:24) at resolve (node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:33) at node_modules/metro/src/DeltaBundler/traverseDependencies.js:412:26 at Array.reduce () at resolveDependencies (node_modules/metro/src/DeltaBundler/traverseDependencies.js:411:33) at processModule (node_modules/metro/src/DeltaBundler/traverseDependencies.js:140:31) at async addDependency (node_modules/metro/src/DeltaBundler/traverseDependencies.js:230:18) at async Promise.all (index 0)

rluvaton commented 7 months ago

Hey, please provide minimal reproduction so we can better help

justankit commented 7 months ago

Hi @rluvaton

Followed these steps in react native app:

npm i --save react-native-crypto

install peer deps

npm i --save react-native-randombytes react-native link react-native-randombytes

install latest rn-nodeify

npm i --save-dev tradle/rn-nodeify

install node core shims and recursively hack package.json files

in ./node_modules to add/update the "browser"/"react-native" field with relevant mappings

./node_modules/.bin/rn-nodeify --hack --install

rn-nodeify will create a shim.js in the project root directory // index.ios.js or index.android.js // make sure you use import and not require!
import './shim.js' import crypto from 'crypto' // ...the rest of your code

React and React Native Details:

"react": "17.0.2", react-native": "0.68.6",

mcollina commented 7 months ago

Unfortunately I know nothing on React Native, so if you create a repository that fails a command it would be helpful.