How to use the contrib-npm


#1

I have a Yale smart alarm system (UK), and found this Yale Alarm System Node.js API Wrapper, which is a Node.js module.

How can I get this to work in Node-RED?

Here's what I tried so far. I found node-red-contrib-npm which "can wrap simple npm modules automatically". Not being exactly sure where to start, I looked up an example node to use this npm wrapper, and came across this example: UK Postcode geolocation lookup. So I installed the node-red-contrib-npm and pasted in the example from the UK Postcode page, but I get this:


#2

Did you install node-red-contrib-npm before you imported a flow that uses it?

edit - sorry, just re-read and see you did install it.

However, the uknown: npm node means the runtime has failed to load the module for some reason. How did you install the node? You'll need to check the log on startup to see if there are any errors whilst trying to load it.


#3

Hi @knolleary,

  • I installed the node through palette manager
  • Just realised the node installed by contrib-npm is actually called "function npm" (as displayed on the left hand menu / palette)

Given above I changed the type of the node in below, before importing it (below shows my changed version). I'm guessing that wasn't the correct thing to do, at that didn't work too.

[{"id":"692367fa.96dc98","type":"inject","z":"9e538f88.61ac7","name":"","topic":"","payload":"SO21 2JN","payloadType":"string","repeat":"","crontab":"","once":false,"x":215,"y":1763,"wires":[["9d6ba542.629458"]]},{"id":"9d6ba542.629458","type":"function npm","z":"9e538f88.61ac7","name":"","func":"// NPM module exposed as variable, npm_module\nreturn npm_module(msg.payload);","npm_module":"uk-postcodes-node","module_style":"function","msg_payload":"callback_error","function_name":"getPostcode","x":399,"y":1763,"wires":[["34825370.cb7dac"]]},{"id":"34825370.cb7dac","type":"debug","z":"9e538f88.61ac7","name":"","active":true,"console":"false","complete":"false","x":611,"y":1763,"wires":[]}]


#4

You need to show use the error(s) you get out of the Node-RED log.