[SOLVED] How to import Moralis into NodeJS in an old way?

Hi, I can’t use moralis-v1/node in my backend because heroku doesn’t deploy it. But the project deploys well with the old moralis 1.5.9 sdk. What would be a correct way of importing/using the old version of moralis in a nodeJs environment? I added it like below, but I’m not sure if it’s correct (some of my code stopped working, but I don’t know exactly if it’s because of that)

import Moralis from 'moralis'

Does the old SDK still work, and how to use it in nodeJS?

p.s.

here are the errors I get from heroku when trying to deploy with moralis-v1/node

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/js-chess-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/js-chess-engine.mjs
       
       ERROR in ./node_modules/xmlhttprequest/lib/XMLHttpRequest.js
       Module not found: Error: Can't resolve 'child_process' in '/tmp/build_6edeab7f/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/js-chess-engine.mjs
       
       ERROR in ./node_modules/xmlhttprequest/lib/XMLHttpRequest.js
       Module not found: Error: Can't resolve 'fs' in '/tmp/build_6edeab7f/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/js-chess-engine.mjs

Thank you,

in node js this is what worked before:

const  Moralis = require('moralis/node')
1 Like

It worked. Thank you.

1 Like