node_pcap
node_pcap copied to clipboard
Installation on Windows 10 still fails because of missing headers
The last comment on #196 is "what about windows?", but there hasn't really been any motion there for a while, even though this seems to have been fixed on OSX and the various Linuces.
A bare npm install
does not work, which is relatively known by this point:
C:\Users\RR\workspace\>npm install pcap
npm ERR! Error while executing:
npm ERR! C:\Program Files\Git\cmd\git.EXE ls-remote -h -t git://github.com/zerouid/node-socketwatcher.git
npm ERR!
npm ERR! fatal: unable to look up github.com (port 9418) (Either the application has not called WSAStartup, or WSAStartup failed. )
npm ERR!
npm ERR! exited with error code: 128
Others have worked around this on non-Windows OSes by installing via https instead, but that also does not work, because it searches for pcap.h
in the recently created node_modules
subfolder and that doesn't exist:
C:\Users\RR\workspace>npm install https://github.com/mranney/node_pcap.git
> [email protected] install C:\Users\RR\workspace\node_modules\socketwatcher
> node-gyp rebuild
C:\Users\RR\workspace\node_modules\socketwatcher>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
socket_watcher.cpp
win_delay_load_hook.cc
c:\users\rr\workspace\node_modules\socketwatcher\socket_watcher.cpp(77): warning C4996: 'Nan::MakeCallb
ack': was declared deprecated [C:\Users\RR\workspace\node_modules\socketwatcher\build\socketwatcher.vcx
proj]
c:\users\rr\workspace\node_modules\nan\nan.h(959): note: see declaration of 'Nan::MakeCallback'
c:\users\rr\workspace\node_modules\socketwatcher\socket_watcher.cpp(116): warning C4996: 'v8::Value::In
t32Value': was declared deprecated [C:\Users\RR\workspace\node_modules\socketwatcher\build\socketwatche
r.vcxproj]
c:\users\rr\.node-gyp\10.14.1\include\node\v8.h(2478): note: see declaration of 'v8::Value::Int32Value'
Creating library C:\Users\RR\workspace\node_modules\socketwatcher\build\Release\socketwatcher.lib
and object C:\Users\RR\workspace\node_modules\socketwatcher\build\Release\socketwatcher.exp
Generating code
All 175 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
Finished generating code
socketwatcher.vcxproj -> C:\Users\RR\workspace\node_modules\socketwatcher\build\Release\\socketwatche
r.node
> [email protected] install C:\Users\RR\workspace\node_modules\pcap
> node-gyp rebuild
C:\Users\RR\workspace\node_modules\pcap>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
pcap_binding.cc
pcap_session.cc
win_delay_load_hook.cc
c:\users\rr\workspace\node_modules\pcap\pcap_binding.cc(2): fatal error C1083: Cannot open include file
: 'pcap/pcap.h': No such file or directory [C:\Users\RR\workspace\node_modules\pcap\build\pcap_binding.
vcxproj]
c:\users\rr\workspace\node_modules\pcap\pcap_session.cc(2): fatal error C1083: Cannot open include file
: 'pcap/pcap.h': No such file or directory [C:\Users\RR\workspace\node_modules\pcap\build\pcap_binding.
vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\RR\workspace\node_modules\pcap
gyp ERR! node -v v10.14.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
I have installed WinPcap, as well as Npcap, its non-deprecated friend which "works on Windows 10"; neither actually makes node not choke here.
Thoughts?
I do not use windows. But the bare npm install
tries to install the socketwatch dependency from github without success.
On Ubuntu I'm able to both npm install
or yarn install
.
What version of npm are you using?
6.4.1.
Other commenters elsewhere have had success with installing via https://
instead of git://
, but as far as I can tell, they're all either using OSX or Ubuntu.
Hello @rreed,
did you find a solution about this problem ?
I unzipped the WinPcap 4.1.2 Developer's Pack in my C:\ directory & added to my environment variable but still not working.
I'm out of idea ...
Me neither, trying to find a solution!
Yes, I used cap instead, since no one ever really responded here. :p It's good enough for my usecases, and might also be for yours, but obviously YMMV.
This module has never supported (and can't easily support) windows. That's because on windows you can't get a pollable socket:
pcap_get_selectable_fd() is not available on Windows.
You can work around this by doing blocking reads in an additional thread, which is what cap
does. This could be merged back into pcap
at some point.
Hi, I fork the repo, and mirgrate to windows platform with npcap, change point:
- use node-addon-api to rewrite, which replace nan
- windows doesn't support pcap_get_selectable_fd, using pcap_next_ex to replace
- we start a new thread to poll pcap_next_ex
welcome review https://github.com/frankie-zeng/node_npcap
hi, awesome! feel free to open a PR with your changes. (I don't have much time now, though... sorry)
some notes if you want to open a PR:
- Don't rename files if it's not needed for your changes, or open a separate PR for that
- Keep in mind the module must still work in other OSes. use
#ifdef
around Windows-specific code - I'm not sure about Windows, but it's generally bad practice to bundle compiled libraries Node addons.
Instead, include the npcap's source code in
deps
and tell node-gyp to build it as well. Link to it statically.