Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on RaspberryPi #31

Open
nervousapps opened this issue Jul 11, 2018 · 4 comments
Open

Crash on RaspberryPi #31

nervousapps opened this issue Jul 11, 2018 · 4 comments

Comments

@nervousapps
Copy link

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;
}
});

@tomas
Copy link
Owner

tomas commented Jul 11, 2018

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?

@nervousapps
Copy link
Author

@tomas
Copy link
Owner

tomas commented Jul 12, 2018

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.

@nervousapps
Copy link
Author

I don't know, maybe it's just on some platform/OS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants