keichi / binary-parser

A blazing-fast declarative parser builder for binary data
MIT License
864 stars 134 forks source link

Trying to instantiate from node-red #174

Closed RossWilliamson closed 2 years ago

RossWilliamson commented 2 years ago

I'm trying to use the binary-parser in a function from node-red. In the setup for the function I set the following:

image

And in the On Message the following:

image

But I get the following error

"TypeError: Cannot read property 'Parser' of undefined"

I'm sure I'm just doing something wrong but the "require" method does not work

keichi commented 2 years ago

Have you installed binary-parser under ~/.node-red?

$ cd ~/.node-red
$ npm install binary-parser
RossWilliamson commented 2 years ago

Have you installed binary-parser under ~/.node-red?

$ cd ~/.node-red
$ npm install binary-parser

Yes I have - It does the copy from the server as expected

keichi commented 2 years ago

Can you try the following? I just tested with Node-RED v2.0.6 and it worked. Btw it seems you don't need to manually install external packages if functionExternalModules is set to true in your ~/.node-red/settings.json. Anyway this is not a binary-parser issue.

var Parser = binaryParser.Parser;

var parser = new Parser();

return msg;