I have to add
/usr/local/lib/node_modules/npm/bin/npm to the exception list. I tried to find and edit
com.apple.sharing.firewall.plist but I didn't found such file anywhere. How can I manually add a specific executable to the exception list?
I don't have enough rep to comment, so I'll attempt an answer...
I wanted to comment since I'd like to clarify why you need to add npm - my install of npm (via homebrew) works OK, without poking a hole in the firewall. Obviously YMMV...! But be aware I've not properly tested this with npm (I tested adding npm, and it continued to work fine.)
I believe you want the application layer firewall. (It's the same firewall you can also access through System Preferences -> Security & Privacy -> Firewall).
My socketfilterfw's API appears to have changed from the one discussed in the linked article. I'd suggest caution, and that you check what the API is for your version before doing anything else:
My version of socketfilterfw doesn't have the "-t" option mentioned in the linked article so I had to use:
/usr/libexec/ApplicationFirewall/socketfilterfw --add /usr/local/bin/npm