Hi I am re-building my pi4 with pivpn, nginx, pihole, influx etc etc on top of 64 bit Bullseye.
I have 4 INA219 modules and previously I had a function (which serviced all 4) starting with "var ina219=global.get('ina219');"
The original installation had a requirement for ina219 in nodered settings.js. In my new install this same entry blocks node-red from starting. I've tried npm install ina219 but that throws up errors.
Can anyone help
thanks
Not sure if this is relevant to your issue...
A user on this forum had problems when he tried to use 64-bit OS on a RPi with HSS.
Part of the install procedure for HSS installs NGINX which you mention in your post.
thanks but I don't think it is relevant in this case.
Can you share that part of your settings.js file ? you may have inserted or removed a required ; or ,
Also when you installed the ina219.js did you do that from within the user directory (usually ~/.node-red ?
there are 2 entries in the settings.js file
// The `https` setting requires the `fs` module. Uncomment the following
// to make it available:
var fs = require("fs");
var i2c = require("i2c-bus");
var ina219 = require("ina219");
module.exports = {
and then further down....
functionGlobalContext: {
ina219:require('ina219'),
fs:require('fs'),
i2c:require('i2c-bus')
},
when I
pi@testPI:~ $ cd /home/pi/.node-red
pi@testPI:~/.node-red $ npm install ina219
I get about a hundred lines of errors
And in that will be the key to the issue.
Unfortunately we cannot see what you don't post.
Just be sure to wrap the log in a code block (hit the </>
button before pasting log)
If you require at the top, there is no need to require again.
Also, have you npm install
ed these modules in your ./node-red
directory?
Edit:
Sorry, I reformatted your post and can now see you tried to install ina219
Unfortunately, without the logs or at least the important parts, it will be difficult to help you.
Ok I found the INA219 file in my old Buster install which I have placed in node-red/node_modules.
I run ....
pi@testPI:~ $ node-red-start
Start Node-RED
Once Node-RED has started, point a browser at http://10.0.0.50:1880
On Pi Node-RED works better with the Firefox or Chrome browser
Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use node-red-log to view the recent log output
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot
To find more nodes and example flows - go to http://flows.nodered.org
Starting as a systemd service.
Error loading settings file: /home/pi/.node-red/settings.js
nodered.service: Succeeded.
nodered.service: Consumed 1.368s CPU time.
Here is my settings.js file
/**
* This is the default settings file provided by Node-RED.
*
* It can contain any valid JavaScript code that will get run when Node-RED
* is started.
*
* Lines that start with // are commented out.
* Each entry should be separated from the entries above and below by a comma ','
*
* For more information about individual settings, refer to the documentation:
* https://nodered.org/docs/user-guide/runtime/configuration
**/
// The `https` setting requires the `fs` module. Uncomment the following
// to make it available:
var fs = require("fs");
var i2c = require("i2c-bus");
var ina219 = require("ina219");
module.exports = {
// the tcp port that the Node-RED web server is listening on
uiPort: process.env.PORT || 1880,
// By default, the Node-RED UI accepts connections on all IPv4 interfaces.
// To listen on all IPv6 addresses, set uiHost to "::",
// The following property can be used to listen on a specific interface. For
// example, the following would only allow connections from the local machine.
//uiHost: "127.0.0.1",
// Retry time in milliseconds for MQTT connections
mqttReconnectTime: 15000,
// Retry time in milliseconds for Serial port connections
serialReconnectTime: 15000,
// Retry time in milliseconds for TCP socket connections
//socketReconnectTime: 10000,
// Timeout in milliseconds for TCP server socket connections
// defaults to no timeout
//socketTimeout: 120000,
// Maximum number of messages to wait in queue while attempting to connect to TCP socket
// defaults to 1000
//tcpMsgQueueSize: 2000,
// Timeout in milliseconds for HTTP request connections
// defaults to 120 seconds
//httpRequestTimeout: 120000,
// The maximum length, in characters, of any message sent to the debug sidebar tab
debugMaxLength: 1000,
// The maximum number of messages nodes will buffer internally as part of their
// operation. This applies across a range of nodes that operate on message sequences.
// defaults to no limit. A value of 0 also means no limit is applied.
//nodeMessageBufferMaxLength: 0,
// To disable the option for using local files for storing keys and certificates in the TLS configuration
// node, set this to true
//tlsConfigDisableLocalFiles: true,
// Colourise the console output of the debug node
//debugUseColors: true,
// The file containing the flows. If not set, it defaults to flows_<hostname>.json
flowFile: 'flows.json',
// To enabled pretty-printing of the flow within the flow file, set the following
// property to true:
//flowFilePretty: true,
// By default, credentials are encrypted in storage using a generated key. To
// specify your own secret, set the following property.
// If you want to disable encryption of credentials, set this property to false.
// Note: once you set this property, do not change it - doing so will prevent
// node-red from being able to decrypt your existing credentials and they will be
// lost.
//credentialSecret: "a-secret-key",
// By default, all user data is stored in a directory called `.node-red` under
// the user's home directory. To use a different location, the following
// property can be used
//userDir: '/home/nol/.node-red/',
// Node-RED scans the `nodes` directory in the userDir to find local node files.
// The following property can be used to specify an additional directory to scan.
//nodesDir: '/home/nol/.node-red/nodes',
// By default, the Node-RED UI is available at http://localhost:1880/
// The following property can be used to specify a different root path.
// If set to false, this is disabled.
//httpAdminRoot: '/admin',
// Some nodes, such as HTTP In, can be used to listen for incoming http requests.
// By default, these are served relative to '/'. The following property
// can be used to specifiy a different root path. If set to false, this is
// disabled.
//httpNodeRoot: '/red-nodes',
// The following property can be used in place of 'httpAdminRoot' and 'httpNodeRoot',
// to apply the same root to both parts.
//httpRoot: '/red',
// When httpAdminRoot is used to move the UI to a different root path, the
// following property can be used to identify a directory of static content
// that should be served at http://localhost:1880/.
//httpStatic: '/home/nol/node-red-static/',
httpStatic: '/home/pi/JMpics',
// The maximum size of HTTP request that will be accepted by the runtime api.
// Default: 5mb
//apiMaxLength: '5mb',
// If you installed the optional node-red-dashboard you can set it's path
// relative to httpRoot
//ui: { path: "ui" },
// Securing Node-RED
// -----------------
// To password protect the Node-RED editor and admin API, the following
// property can be used. See http://nodered.org/docs/security.html for details.
//adminAuth: {
// type: "credentials",
// users: [{
// username: "admin",
// password: "$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.",
// permissions: "*"
// }]
//},
// To password protect the node-defined HTTP endpoints (httpNodeRoot), or
// the static content (httpStatic), the following properties can be used.
// The pass field is a bcrypt hash of the password.
// See http://nodered.org/docs/security.html#generating-the-password-hash
//httpNodeAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."},
//httpStaticAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."},
// The following property can be used to enable HTTPS
// See http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
// for details on its contents.
// This property can be either an object, containing both a (private) key and a (public) certificate,
// or a function that returns such an object:
//// https object:
//https: {
// key: require("fs").readFileSync('privkey.pem'),
// cert: require("fs").readFileSync('cert.pem')
//},
////https function:
// https: function() {
// // This function should return the options object, or a Promise
// // that resolves to the options object
// return {
// key: require("fs").readFileSync('privkey.pem'),
// cert: require("fs").readFileSync('cert.pem')
// }
// },
// The following property can be used to refresh the https settings at a
// regular time interval in hours.
// This requires:
// - the `https` setting to be a function that can be called to get
// the refreshed settings.
// - Node.js 11 or later.
//httpsRefreshInterval : 12,
// The following property can be used to cause insecure HTTP connections to
// be redirected to HTTPS.
//requireHttps: true,
// The following property can be used to disable the editor. The admin API
// is not affected by this option. To disable both the editor and the admin
// API, use either the httpRoot or httpAdminRoot properties
//disableEditor: false,
// The following property can be used to configure cross-origin resource sharing
// in the HTTP nodes.
// See https://github.com/troygoode/node-cors#configuration-options for
// details on its contents. The following is a basic permissive set of options:
//httpNodeCors: {
// origin: "*",
// methods: "GET,PUT,POST,DELETE"
//},
// If you need to set an http proxy please set an environment variable
// called http_proxy (or HTTP_PROXY) outside of Node-RED in the operating system.
// For example - http_proxy=http://myproxy.com:8080
// (Setting it here will have no effect)
// You may also specify no_proxy (or NO_PROXY) to supply a comma separated
// list of domains to not proxy, eg - no_proxy=.acme.co,.acme.co.uk
// The following property can be used to add a custom middleware function
// in front of all http in nodes. This allows custom authentication to be
// applied to all http in nodes, or any other sort of common request processing.
//httpNodeMiddleware: function(req,res,next) {
// // Handle/reject the request, or pass it on to the http in node by calling next();
// // Optionally skip our rawBodyParser by setting this to true;
// //req.skipRawBodyParser = true;
// next();
//},
// The following property can be used to add a custom middleware function
// in front of all admin http routes. For example, to set custom http
// headers
// httpAdminMiddleware: function(req,res,next) {
// // Set the X-Frame-Options header to limit where the editor
// // can be embedded
// //res.set('X-Frame-Options', 'sameorigin');
// next();
// },
// The following property can be used to pass custom options to the Express.js
// server used by Node-RED. For a full list of available options, refer
// to http://expressjs.com/en/api.html#app.settings.table
//httpServerOptions: { },
// The following property can be used to verify websocket connection attempts.
// This allows, for example, the HTTP request headers to be checked to ensure
// they include valid authentication information.
//webSocketNodeVerifyClient: function(info) {
// // 'info' has three properties:
// // - origin : the value in the Origin header
// // - req : the HTTP request
// // - secure : true if req.connection.authorized or req.connection.encrypted is set
// //
// // The function should return true if the connection should be accepted, false otherwise.
// //
// // Alternatively, if this function is defined to accept a second argument, callback,
// // it can be used to verify the client asynchronously.
// // The callback takes three arguments:
// // - result : boolean, whether to accept the connection or not
// // - code : if result is false, the HTTP error status to return
// // - reason: if result is false, the HTTP reason string to return
//},
// The following property can be used to seed Global Context with predefined
// values. This allows extra node modules to be made available with the
// Function node.
// For example,
// functionGlobalContext: { os:require('os') }
// can be accessed in a function block as:
// global.get("os")
functionGlobalContext: {
ina219:require('ina219'),
fs:require('fs'),
i2c:require('i2c-bus')
// os:require('os'),
// jfive:require("johnny-five"),
// j5board:require("johnny-five").Board({repl:false})
},
// `global.keys()` returns a list of all properties set in global context.
// This allows them to be displayed in the Context Sidebar within the editor.
// In some circumstances it is not desirable to expose them to the editor. The
// following property can be used to hide any property set in `functionGlobalContext`
// from being list by `global.keys()`.
// By default, the property is set to false to avoid accidental exposure of
// their values. Setting this to true will cause the keys to be listed.
exportGlobalContextKeys: false,
// Context Storage
// The following property can be used to enable context storage. The configuration
// provided here will enable file-based context that flushes to disk every 30 seconds.
// Refer to the documentation for further options: https://nodered.org/docs/api/context/
//
contextStorage: {
default: {
module:"localfilesystem",
config: {
dir:"~/.node-red",
base:"context",
cache:true,
flushInterval:30
}
},
},
// The following property can be used to order the categories in the editor
// palette. If a node's category is not in the list, the category will get
// added to the end of the palette.
// If not set, the following default order is used:
//paletteCategories: ['subflows', 'common', 'function', 'network', 'sequence', 'parser', 'storage'],
// Configure the logging output
logging: {
// Only console logging is currently supported
console: {
// Level of logging to be recorded. Options are:
// fatal - only those errors which make the application unusable should be recorded
// error - record errors which are deemed fatal for a particular request + fatal errors
// warn - record problems which are non fatal + errors + fatal errors
// info - record information about the general running of the application + warn + error + fatal errors
// debug - record information which is more verbose than info + info + warn + error + fatal errors
// trace - record very detailed logging + debug + info + warn + error + fatal errors
// off - turn off all logging (doesn't affect metrics or audit)
level: "info",
// Whether or not to include metric events in the log output
metrics: false,
// Whether or not to include audit events in the log output
audit: false
}
},
// Customising the editor
editorTheme: {
projects: {
// To enable the Projects feature, set this value to true
enabled: false
}
}
}
Why?
It is likely there is a compilation step in the installation of ina219
and that is failing during install. Which will be described in the npm install
output.
Let me try to make this clear:
Step 1. install ina219
using npm
in the ./node-red
directory
- if it finishes without error - THEN we can look at why node-red does not start
- if it finishes with error, stop!, there is no point telling us about your node-red set-up
Step 2.
- There is no step 2 until you correctly install
ina219
PS: looking at your settings.js, I suspect you are using an old version (copied from an old install?) or you have an old version of node-red installed on your new machine. - however, for now, this is unimportant
EDIT:
Was there a question in your last post?
Is it now working:?
I have assumed you are reporting this because it didnt work?
Sorry if I'm unclear.
The install is all new. The settings.js file is in fact an old copy in an effort to make it work. Anyway if I use the newest version and add the ina219 require line it blocks the node-red from starting. So you are saying that it is not enough to copy the ina219 file. (excuse my lack of knowledge)...
Here is the result of trying to install ina219
PS the system tells me the file contents are too large to post so this is only the first quarter. It means nothing to me.
pi@testPI:~/.node-red $ npm install ina219
npm ERR! code 1
npm ERR! path /home/pi/.node-red/node_modules/ina219/node_modules/i2c-bus
npm ERR! command failed
npm ERR! command sh -c -- node-gyp rebuild
npm ERR! make: Entering directory '/home/pi/.node-red/node_modules/ina219/node_modules/i2c-bus/build'
npm ERR! CXX(target) Release/obj.target/i2c/src/i2c.o
npm ERR! make: Leaving directory '/home/pi/.node-red/node_modules/ina219/node_modules/i2c-bus/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.20.1 | linux | arm64
npm ERR! gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/home/pi/.node-red/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/pi/.node-red/node_modules/ina219/node_modules/i2c-bus/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/pi/.node-red/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/pi/.cache/node-gyp/16.20.1/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/home/pi/.cache/node-gyp/16.20.1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/home/pi/.node-red/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/home/pi/.cache/node-gyp/16.20.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/pi/.node-red/node_modules/ina219/node_modules/i2c-bus',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../../nan/nan_converters.h:67,
npm ERR! from ../../nan/nan.h:202,
npm ERR! from ../src/i2c.cc:2:
npm ERR! ../../nan/nan_converters_43_inl.h: In static member function ‘static Nan::imp::ToFactoryBase<v8::Boolean>::return_t Nan::imp::ToFactory<v8::Boolean>::convert(v8::Local<v8::Value>)’:
npm ERR! ../../nan/nan_converters_43_inl.h:18:67: error: cannot convert ‘v8::Local<v8::Context>’ to ‘v8::Isolate*’
npm ERR! 18 | val->To ## TYPE(v8::Isolate::GetCurrent()->GetCurrentContext()) \
npm ERR! | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
npm ERR! | |
npm ERR! | v8::Local<v8::Context>
npm ERR! ../../nan/nan_converters_43_inl.h:22:1: note: in expansion of macro ‘X’
npm ERR! 22 | X(Boolean)
npm ERR! | ^
npm ERR! In file included from /home/pi/.cache/node-gyp/16.20.1/include/node/node.h:73,
npm ERR! from ../src/i2c.cc:1:
npm ERR! /home/pi/.cache/node-gyp/16.20.1/include/node/v8.h:3086:37: note: initializing argument 1 of ‘v8::Local<v8::Boolean> v8::Value::ToBoolean(v8::Isolate*) const’
npm ERR! 3086 | Local<Boolean> ToBoolean(Isolate* isolate) const;
npm ERR! | ~~~~~~~~~^~~~~~~
npm ERR! In file included from ../../nan/nan_converters.h:67,
npm ERR! from ../../nan/nan.h:202,
npm ERR! from ../src/i2c.cc:2:
npm ERR! ../../nan/nan_converters_43_inl.h: In static member function ‘static Nan::imp::ValueFactoryBase<bool>::return_t Nan::imp::ToFactory<bool>::convert(v8::Local<v8::Value>)’:
npm ERR! ../../nan/nan_converters_43_inl.h:37:55: error: cannot convert ‘v8::Local<v8::Context>’ to ‘v8::Isolate*’
npm ERR! 37 | return val->NAME ## Value(isolate->GetCurrentContext()); \
npm ERR! | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
npm ERR! | |
npm ERR! | v8::Local<v8::Context>
npm ERR! ../../nan/nan_converters_43_inl.h:40:1: note: in expansion of macro ‘X’
npm ERR! 40 | X(bool, Boolean)
npm ERR! | ^
npm ERR! In file included from /home/pi/.cache/node-gyp/16.20.1/include/node/node.h:73,
npm ERR! from ../src/i2c.cc:1:
npm ERR! /home/pi/.cache/node-gyp/16.20.1/include/node/v8.h:3096:30: note: initializing argument 1 of ‘bool v8::Value::BooleanValue(v8::Isolate*) const’
npm ERR! 3096 | bool BooleanValue(Isolate* isolate) const;
npm ERR! | ~~~~~~~~~^~~~~~~
npm ERR! In file included from ../../nan/nan_new.h:189,
npm ERR! from ../../nan/nan.h:203,
npm ERR! from ../src/i2c.cc:2:
npm ERR! ../../nan/nan_implementation_12_inl.h: In static member function ‘static Nan::imp::FactoryBase<v8::Function>::return_t Nan::imp::Factory<v8::Function>::New(Nan::FunctionCallback, v8::Local<v8::Value>)’:
npm ERR! ../../nan/nan_implementation_12_inl.h:103:42: error: cannot convert ‘v8::Isolate*’ to ‘v8::Local<v8::Context>’
npm ERR! 103 | return scope.Escape(v8::Function::New( isolate
npm ERR! | ^~~~~~~
npm ERR! | |
npm ERR! | v8::Isolate*
npm ERR! In file included from /home/pi/.cache/node-gyp/16.20.1/include/node/node.h:73,
npm ERR! from ../src/i2c.cc:1:
npm ERR! /home/pi/.cache/node-gyp/16.20.1/include/node/v8.h:4754:22: note: initializing argument 1 of ‘static v8::MaybeLocal<v8::Function> v8::Function::New(v8::Local<v8::Context>, v8::FunctionCallback, v8::Local<v8::Value>, int, v8::ConstructorBehavior, v8::SideEffectType)’
npm ERR! 4754 | Local<Context> context, FunctionCallback callback,
npm ERR! | ~~~~~~~~~~~~~~~^~~~~~~
npm ERR! In file included from ../../nan/nan_new.h:189,
npm ERR! from ../../nan/nan.h:203,
npm ERR! from ../src/i2c.cc:2:
npm ERR! ../../nan/nan_implementation_12_inl.h: In static member function ‘static Nan::imp::FactoryBase<v8::StringObject>::return_t Nan::imp::Factory<v8::StringObject>::New(v8::Local<v8::String>)’:
npm ERR! ../../nan/nan_implementation_12_inl.h:337:37: error: no matching function for call to ‘v8::StringObject::New(v8::Local<v8::String>&)’
npm ERR! 337 | return v8::StringObject::New(value).As<v8::StringObject>();
npm ERR! | ^
npm ERR! In file included from /home/pi/.cache/node-gyp/16.20.1/include/node/node.h:73,
npm ERR! from ../src/i2c.cc:1:
npm ERR! /home/pi/.cache/node-gyp/16.20.1/include/node/v8.h:6196:23: note: candidate: ‘static v8::Local<v8::Value> v8::StringObject::New(v8::Isolate*, v8::Local<v8::String>)’
npm ERR! 6196 | static Local<Value> New(Isolate* isolate, Local<String> value);
npm ERR! | ^~~
npm ERR! /home/pi/.cache/node-gyp/16.20.1/include/node/v8.h:6196:23: note: candidate expects 2 arguments, 1 provided
npm ERR! In file included from ../../nan/nan_new.h:189,
npm ERR! from ../../nan/nan.h:203,
npm ERR! from ../src/i2c.cc:2:
npm ERR! ../../nan/nan_implementation_12_inl.h:337:58: error: expected primary-expression before ‘>’ token
npm ERR! 337 | return v8::StringObject::New(value).As<v8::StringObject>();
npm ERR! | ^
npm ERR! ../../nan/nan_implementation_12_inl.h:337:60: error: expected primary-expression before ‘)’ token
npm ERR! 337 | return v8::StringObject::New(value).As<v8::StringObject>();
npm ERR! | ^
npm ERR! In file included from ../src/i2c.cc:2:
I think Steve has made that clear.
Remove the file that you copied, and then;
cd && cd .node-red
followed by
npm install ina219
then restart node-RED.
Yup, that will never work - you have compilation errors.
Did you by chance copy ~/.node-red/node_modules
from the old device?
If so, you need to delete that entire dir (the ~./node-red/node_modules
directory) - then, do an npm install
at ~./node-red
module so that it re-installs fresh versions and compiles anything it needs.
Question:
How did you install Node-RED? Did you use the official install script?
OK i removed the ina219 file and tried again and it failed. I noticed in the error message a requirement for i2c-bus so I npm installed it successfully.
Then tried again
pi@testPI:~/.node-red $ npm install ina219
npm ERR! code 1
npm ERR! path /home/pi/.node-red/node_modules/ina219/node_modules/i2c-bus
npm ERR! command failed
npm ERR! command sh -c -- node-gyp rebuild
npm ERR! make: Entering directory '/home/pi/.node-red/node_modules/ina219/node_modules/i2c-bus/build'
npm ERR! CXX(target) Release/obj.target/i2c/src/i2c.o
npm ERR! make: Leaving directory '/home/pi/.node-red/node_modules/ina219/node_modules/i2c-bus/build'
with about a hundred more lines.
I'm sorry to be a nuisance but...
PS yes node-red install via official script.
Did that and then tried again
pi@testPI:~/.node-red $ npm install ina219
npm ERR! code 1
npm ERR! path /home/pi/.node-red/node_modules/ina219/node_modules/i2c-bus
npm ERR! command failed
npm ERR! command sh -c -- node-gyp rebuild
npm ERR! make: Entering directory '/home/pi/.node-red/node_modules/ina219/node_modules/i2c-bus/build'
npm ERR! CXX(target) Release/obj.target/i2c/src/i2c.o
npm ERR! make: Leaving directory '/home/pi/.node-red/node_modules/ina219/node_modules/i2c-bus/build'
npm ERR! gyp info it worked if it ends with ok
Looking at the NPM package, it is 4 years old. It has a dependency to "i2c-bus":"^1.1.1"
- I believe this may be the issue. i2c-bus
current version is 5.2.2
BUT
The git package has been updated (author just hasnt published the latest version to NPM - something that should be raised as an issue on the repository)
So you could try installing directly from github instead:
cd ~/.node-red
npm install brettmarl/node-ina219
... since it is using i2c-bus v4.x : see here in the github package.json
Other Options
clone and fix
- clone
node-ina219
repositorygit clone https://github.com/brettmarl/node-ina219.git
- update
package.json
- setting the i2c dependency up to5.2.2
- install your local, updated version
cd ~/.node-red npm install ~/dir/where/you-cloned-the-repo-to
dirty copy + fix
- download
ina219.js
- save it to
~/node-red/ina219.js
- install latest
i2c-bus
~npm i i2c-bus@latest
- require
ina219.js
in your settings file (you may need to move this to node_modules)
--- neither of these options are guaranteed to work - i2c-bus has jumped a major version since this node was last updated. You may need to look for other nodes / ideas. ---
Also, there are several alternatives on NPM. This one: ina219-sync is quite recent. It was updated a few months ago and uses i2c-bus
5.2.2
You would need to do...
cd ~/.node-red
npm i ina219-sync
then
const ina219 = require('ina219-sync');
const sensor = new ina219();
sensor.calibrate32V1A();
module.exports = {
// ... other stuff ...
functionGlobalContext: {
ina219: sensor
}
// ... other stuff ...
}
or alternatively
const ina219 = require('ina219-sync');
module.exports = {
// ... other stuff ...
functionGlobalContext: {
ina219: ina219
}
// ... other stuff ...
}
Absolutely fantastic. Works now.
How do you guys know so much?
I love this forum, everybody is so willing to help lost souls like myself.
PS
So glad it wasn't entirely something stupid I'd done.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.