network
network copied to clipboard
Crash on RaspberryPi
On raspberry with node version 10.6.0, I have the error : /home/pi/rdr/node_modules/network/lib/linux.js:87 nics[key].forEach(function(type) { ^
TypeError: nics[key].forEach is not a function at Object.exports.get_network_interfaces_list (/home/pi/rdr/node_modules/network/lib/linux.js:87:17) at nic_by_name (/home/pi/rdr/node_modules/network/lib/index.js:21:16) at /home/pi/rdr/node_modules/network/lib/index.js:98:5 at /home/pi/rdr/node_modules/network/lib/linux.js:26:5 at ChildProcess.exithandler (child_process.js:282:7) at ChildProcess.emit (events.js:182:13) at maybeClose (internal/child_process.js:961:16) at Socket.stream.socket.on (internal/child_process.js:380:11) at Socket.emit (events.js:182:13) at Pipe._handle.close (net.js:598:12)
To make it work, just change line 87:
nics[key].forEach(function(type) { if (type.family == 'IPv4') { obj.ip_address = type.address; } });
TO :
Object.keys(nics[key]).forEach(function(type) { if (type.family == 'IPv4') { obj.ip_address = type.address; } });
I see. Does this work on older versions of Node? (v4.x.x, v6.x.x)
Can you link to the relevant version in the Node changelog to see how/when/why this behaviour changed?
Your response is just here :) 👍 https://stackoverflow.com/questions/31096596/why-is-foreach-not-a-function-for-this-object/31096661
Yikes. I AM aware that POJO's don't respond to .forEach
as Arrays do. I'm asking you to show in which version of Node.js did the behaviour of os.networkInterfaces
change.
I don't know, maybe it's just on some platform/OS