readable-stream icon indicating copy to clipboard operation
readable-stream copied to clipboard

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

Open justankit opened this issue 1 year ago • 3 comments

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)

justankit avatar Apr 05 '24 11:04 justankit

Hey, please provide minimal reproduction so we can better help

rluvaton avatar Apr 06 '24 18:04 rluvaton

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",

justankit avatar Apr 07 '24 03:04 justankit

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

mcollina avatar Apr 07 '24 08:04 mcollina