I’m trying to setup my MoralisProvider in my React project. I followed the boilerplate React setup and have my app id and server url configured
const App: FC = () => (
<MoralisProvider
appId={config.moralis.appId}
serverUrl={config.moralis.serverUrl}>
<App />
</MoralisProvider>
);
I am using webpack as well (not en expert with webpack). I got the polyfill errors and fixed those but am now getting this errors in the browser console.
Uncaught TypeError: Cannot read properties of undefined (reading 'WordArray')
at enc-base64.js:20
at enc-base64.js:131
at enc-base64.js:4
at Object../node_modules/crypto-js/enc-base64.js (enc-base64.js:14)
at __webpack_require__ (bootstrap:19)
at aes.js:4
at Object../node_modules/crypto-js/aes.js (aes.js:14)
at __webpack_require__ (bootstrap:19)
at Object../node_modules/moralis/lib/browser/CryptoController.js
(CryptoController.js:9)
at __webpack_require__ (bootstrap:19)
This happens when Moralis is initialized, if I comment the provider the error goes away. I think it’s something with webpack but not sure exactly what the solution is.
Here is my package.json
"dependencies": {
"@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.6",
"@babel/preset-react": "^7.14.5",
"@material-ui/core": "4.12.2",
"@material-ui/styles": "^4.11.4",
"@sentry/react": "6.10.0",
"@sentry/tracing": "6.10.0",
"@walletconnect/web3-provider": "^1.6.5",
"babel-loader": "^8.2.2",
"color": "4.0.0",
"lodash": "4.17.21",
"moralis": "^0.0.45",
"node-polyfill-webpack-plugin": "^1.1.4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-moralis": "^0.2.3",
"react-router-dom": "5.2.0"
},
"devDependencies": {
"@types/color": "3.0.2",
"@types/lodash": "4.14.171",
"@types/react": "17.0.14",
"@types/react-dom": "17.0.9",
"@types/react-router-dom": "5.1.8",
"@typescript-eslint/eslint-plugin": "4.28.4",
"@typescript-eslint/parser": "4.28.4",
"copy-webpack-plugin": "9.0.1",
"css-loader": "6.2.0",
"dotenv": "10.0.0",
"eslint": "7.31.0",
"eslint-plugin-react": "7.24.0",
"eslint-plugin-react-hooks": "4.2.0",
"file-loader": "6.2.0",
"html-webpack-plugin": "5.3.2",
"husky": "7.0.1",
"lint-staged": "11.0.1",
"prettier": "2.3.2",
"style-loader": "3.2.1",
"ts-loader": "9.2.3",
"tsconfig-paths-webpack-plugin": "3.5.1",
"typescript": "4.3.5",
"url-loader": "4.1.1",
"webpack": "^5.50.0",
"webpack-cli": "4.7.2",
"webpack-dev-server": "3.11.2"
}
dev environment