[SOLVED] Heroku build failed due to magic sdk and others

Hello,

I tried to deploy my backend to heroku, but the build keeps failing due to a few moralis related dependencies. I tried deleting node modules and lock file and reinstalling dependencies. I also tried manually installing those dependencies that show up in the errors, but they still persist. What can you suggest?

Errors and my package json are below.

WARNING in ./node_modules/magic-sdk/dist/es/index.js 1:266-273
       Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
        @ ./node_modules/moralis-v1/lib/node/Web3Connector/MagicWeb3Connector.js
        @ ./node_modules/moralis-v1/lib/node/MoralisWeb3.js
        @ ./node_modules/moralis-v1/lib/node/Parse.js
        @ ./node_modules/moralis-v1/node.js
        @ ./lib/engine.mjs
       
       WARNING in ./node_modules/magic-sdk/dist/es/index.js 1:422-429
       Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
        @ ./node_modules/moralis-v1/lib/node/Web3Connector/MagicWeb3Connector.js
        @ ./node_modules/moralis-v1/lib/node/MoralisWeb3.js
        @ ./node_modules/moralis-v1/lib/node/Parse.js
        @ ./node_modules/moralis-v1/node.js
        @ ./lib/engine.mjs
       
       ERROR in ./node_modules/xmlhttprequest/lib/XMLHttpRequest.js
       Module not found: Error: Can't resolve 'child_process' in '/tmp/build_07c2521e/node_modules/xmlhttprequest/lib'
        @ ./node_modules/xmlhttprequest/lib/XMLHttpRequest.js 15:12-36
        @ ./node_modules/moralis-v1/lib/node/RESTController.js
        @ ./node_modules/moralis-v1/lib/node/Parse.js
        @ ./node_modules/moralis-v1/node.js
        @ ./lib/engine.mjs
       
       ERROR in ./node_modules/xmlhttprequest/lib/XMLHttpRequest.js
       Module not found: Error: Can't resolve 'fs' in '/tmp/build_07c2521e/node_modules/xmlhttprequest/lib'
        @ ./node_modules/xmlhttprequest/lib/XMLHttpRequest.js 16:9-22
        @ ./node_modules/moralis-v1/lib/node/RESTController.js
        @ ./node_modules/moralis-v1/lib/node/Parse.js
        @ ./node_modules/moralis-v1/node.js
        @ ./lib/engine.mjs

My package json

“dependencies”: {
“conventional-changelog-cli”: “^2.0.34”,
“es6-template-strings”: “^2.0.1”,
“eslint”: “^7.0.0”,
“eslint-config-standard”: “^14.1.1”,
“eslint-plugin-import”: “^2.20.2”,
“eslint-plugin-node”: “^11.1.0”,
“eslint-plugin-promise”: “^4.2.1”,
“eslint-plugin-standard”: “^4.0.1”,
“fastify”: “^2.14.1”,
“fastify-cors”: “^3.0.3”,
“magic-sdk”: “^9.0.0”,
“moralis-v1”: “^1.11.0”,
“nodemon”: “^2.0.3”,
“webpack”: “^4.43.0”,
“webpack-cli”: “^4.9.1”,
@walletconnect/web3-provider”: “^1.7.7”,
@web3auth/web3auth”: “^1.2.0”,
“moralis”: “^1.5.9”
}

Thank you

The issue resolved. The issue was due to the moralis-v1 dependency. After I removed/replaced it with moralis: 1.59 the build succeded.

1 Like