0

I would like to use npm talib module within a meteorjs application.
I followed the instruction here and I added this to the packages.json file:

{
  "talib" :   "0.6.0"
}

After running meteor the module talib.node is there in the node_modules/talib/build/Release/ folder.
Then I wrote the following:

if (Meteor.isServer) {
  var Talib = Meteor.npmRequire('talib');
  var talib = new Talib();
}

The Talib object is created and can be logged, like this:

{ version: '0.6.0',
  functions: 
  [ { name: 'ADD',
     group: 'Math Operators',
     ...
     }
  ],
  functionUnstIds: 
   { TA_FUNC_UNST_ADX: 0,
     TA_FUNC_UNST_ADXR: 1,
     ...
   }
 }

The line var talib = new Talib() gives instead this error:

 TypeError: object is not a function

What I am doing wrong?

Stefano Piovesan
  • 1,185
  • 3
  • 19
  • 37
  • Well, it's obvious with the log: You don't have a function but an object with multiple fields (`versions`, `functions`...). Calling `new` with that object is going to fail. I'm not sure if this is because the NPM library has not been imported correctly using `Meteor` or if it's an issue with the library API, since I have not worked with either ones. – Kyll Jul 29 '15 at 21:47
  • Yes, you are right, it works as an object; I can call properties and methods directly on the object returned from `var talib = Meteor.npmRequire('talib');`, as `console.log("TALib Version: " + talib.version);` – Stefano Piovesan Jul 30 '15 at 06:02

0 Answers0