Hi,
I'm writing a custom node for Node-red (see versions below) but i require other modules/scripts in it.
When i add the require line (see my code) it failes to show up in the node-red brwoser interface. when i comment out the require lines i can see my node.
Ofcorse my node doesn't work as it requires the GPIO package...
What am i doing wrong?
the 'error' code:
26 Jan 12:40:30 - [info] Waiting for missing types to be registered:
26 Jan 12:40:30 - [info] - input-test
My code (JS)
module.exports = function(RED) {
const CAN = require('mcpreadwrite');
const SPI = require('spi-device');
const gpiop = require('rpi-gpio').promise;
//const gpiop = require('rpi-gpio').promise;
function INPUTTEST(config) {
RED.nodes.createNode(this,config);
//this.on('input', function(msg) {
//
// this.send(msg);
//});
gpiop.setup(config.pin, gpiop.DIR_IN, gpiop.EDGE_BOTH);
gpiop.on('change', function(channel, value) {
msg.payload = value;
this.send(msg);
});
}
RED.nodes.registerType("input-test", INPUTTEST);
}
HTML:
<script type="text/javascript">
RED.nodes.registerType('input-test',{
category: 'US_Input',
color: '#38F6F6',
defaults: {
pin: {value:0}
},
outputs:1,
icon: "serial.png",
label: "input-test"
});
</script>
<script type="text/x-red" data-template-name="input-test">
<div class="form-row">
<label for="node-input-pin"><i class="icon-tag"></i>Pin</label>
<input id="node-input-pin">
</div>
</script>
<script type="text/x-red" data-help-name="input-test">
<p>Unwritten</p>
</script>
JSON:
{
"name": "input",
"version": "1.0.0",
"description": "Controll the US-Input cart",
"main": "input.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"mcpreadwrite": "file:../MCP2515-ReadWrite",
"rpi-gpio": "^2.1.7",
"spi-device": "^3.1.0"
},
"node-red": {
"nodes": {
"main": "input.js"
}
}
}
NPM version: 6.14.10
Node.jS version: v12.20.1
Node-Red version: v1.2.6
Running on a RPi 3B+: Linux version 5.4.79-v7+ (dom@buildbot) (gcc version 8.4.0 (Ubuntu/Linaro 8.4.0-3ubuntu1))
Edit reason: added OS