Node.ports is a property that returns a collection – it is not a function.
part.ports.each(port => ...);