I am getting this error:
Module not found: Error: You attempted to import /my-project/node_modules/crypto-browserify/index.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
I need to use the crypto
library which is no longer autoincluded. I followed the react-app-rewired
instructions to override this dependency, and instead use crypto-browserify
, but then this error shows up.
This is an excerpt of my config-overrides.js
file:
Object.assign(fallback, {
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("stream-browserify"),
assert: require.resolve("assert"),
http: require.resolve("stream-http"),
https: require.resolve("https-browserify"),
os: require.resolve("os-browserify"),
url: require.resolve("url"),
});
I haven't been able to find an answer to this problem yet.
Any idea how to resolve this issue? Thanks!
Relevant Dependencies:
react: "^18.2.0"
crypto-browserify: "^3.12.0"
react-scripts: "5.0.1"
react-app-rewired: "^2.2.1" - // As dev dependency