Getting a Compile error if Javascript action uses web3 node js module

0
Hi, Getting a Compile error if Javascript action uses web3 node js module I am trying to connect the mendix client to the web3 of metamask running on same browser. So my javascript action has this line: import Web3 from 'web3'; and I have added web3 library in javascriptsource/signin/actions/node_modules I am getting compile error when starting server.   Compile Error: ********* ModuleNotFoundError: Module not found: Error: Can't resolve 'crypto' in 'C:\.....\javascriptsource\signin\actions\node_modules\web3-eth-accounts\lib'   BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.   If you want to include a polyfill, you need to: - add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }' - install 'crypto-browserify' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "crypto": false } at C:\Program Files\Mendix\9.10.1.37625\modeler\tools\node\node_modules\webpack\lib\Compilation.js:2011:28 at ... resolve 'crypto' in 'C:\.....\javascriptsource\signin\actions\node_modules\web3-eth-accounts\lib' Parsed request is a module using description file: C:\.......\javascriptsource\signin\actions\node_modules\web3-eth-accounts\package.json (relative path: ./lib) Field 'browser' doesn't contain a valid alias configuration *********   I tried troubleshooting by editing javascriptsource/signin/actions/package.json by adding "devDependencies": { ... }, "browser": { "crypto": false } Also tried troubleshooting by trying to create a new file webpack.config.js, under src of errored module, with this content: module.exports = { resolve: { fallback: { "crypto": false }, }, };   Nothing helped so far. Any pointers would be appreciated.
asked
1 answers
0

I think the crypto library you added is a NodeJS library while you should have installed "crypto-browserify" 

this is a polyfill for the same backend library but made to run on browsers.

answered