Node.js server api (NON-FRONTEND)

Hi devs,

I’m searching for alternative use of moralis api without any frontend application.

For my backed I use Node.js version 12 and Typescript compilations 3.9.10. When compilation is proceeding an error occurs. I searched over all sources and did not found any solution withou for example react-js.
I will not use any frontend, except Express to make requests implemented more easily.
Can I get any help for that topic?

node_modules/moralis/types/index.d.ts(244,25): chyba TS2339: Property 'off' does not exist on type 'EventEmitter'.
		npm ERR! code ELIFECYCLE
		npm ERR! errno 1
		npm ERR! mania[email protected] build: `tsc --build`
		npm ERR! Exit status 1

It should work fine in nodejs. I don’t know in particular about typescript.

Node v15.0.1, moralis v1.5.4, typescript v4.6.2


        let moralisURI = BaseApp.settings['servers'].Moralis.ServerURI;
        let moralisID = BaseApp.settings['servers'].Moralis.ApplicationId;
        let moralisKey = BaseApp.settings['servers'].Moralis.MasterKey;
        let moralisSecret = BaseApp.settings['servers'].Moralis.SecretKey;

        try {
            Moralis.start({ serverUrl: moralisURI, appId: moralisID, masterKey: moralisKey, moralisSecret: moralisSecret });
        } catch (e) {

Required fix inside index.d.ts -> moralis/node

Final state:

TypeError: Cannot read property 'start' of undefined
    at Function.config (C:\Users\Phanteks\source\repos\ManiaplanetScoreServer\modules\universe-island\app.js:21:28)
    at Object.<anonymous> (C:\Users\Phanteks\source\repos\ManiaplanetScoreServer\server.js:398:38)
    at Module._compile (node:internal/modules/cjs/loader:1080:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1112:10)
    at Module.load (node:internal/modules/cjs/loader:948:32)
    at Function.Module._load (node:internal/modules/cjs/loader:789:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:72:12)
    at node:internal/main/run_main_module:17:47

try with latest version of Moralis SDK, 1.5.5, it had a fix for eventEmitter

Hi, for node v15.0.1 the EventEmitter is not a fix.
There was maybe added new event type in version after.

Moralis version 1.5.5 still has same issue with missing start while typescript is used.

Next step: Query does not return results

TypeError: Cannot read properties of undefined (reading 'length')
    at Object.request (Server\node_modules\moralis\lib\node\RESTController.js:306:17)
    at Object.find (Server\node_modules\moralis\lib\node\ParseQuery.js:2692:27)
    at ParseQuery.find (Server\node_modules\moralis\lib\node\ParseQuery.js:791:23)
    at Server\modules\universe-island\app.js:23:39
    at Layer.handle [as handle_request] (Server\node_modules\express\lib\router\layer.js:95:5)
    at next (Server\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (Server\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (Server\node_modules\express\lib\router\layer.js:95:5)
    at Server\node_modules\express\lib\router\index.js:281:22
    at Function.process_params (Server\node_modules\express\lib\router\index.js:341:12)

what line gave that error?


how do you know that is the line?

you can try the syntax from documentation:

const Monster = Moralis.Object.extend("Monster");
const query = new Moralis.Query(Monster);
query.equalTo("ownerName", "Aegon");
const results = await query.find();

This was issue:

Can someone please update the documentation, that the name of outer variable must be called same as input argument?


So that means, firs issue is issue of typescript compilation.
The second one, that is needed use: const MoralisCall = require('moralis/node');
Instead: import Moralis from 'moralis/node';

What and where needs to be updated in the documentation?

If possible, please there:

These temporary variables may be named differently any javascript editors does not show error.
Then it causes error with length

Hello, you can alway make a pr to the repo

well you can do const Moralis = require('moralis/node');
it is the same thing
if import doesnt work, you may need to use require (but require should work for nodejs)

and you may need to extend from an object before querying it
and you also have to have data in the object
and what is query.first() supposed to do ?

Now is all working from:
const MoralisCall = require(‘moralis/node’);

But I’m using typescript and for that is required to have functional interface. In case there will be no fix, I would angrily write a typescript wrapper. At least now it complicates work a lot.

Thank you all for help