`npm install pcap` fails (node v5.4.1, npm 3.5.3)
rgrannell1 opened this issue · 24 comments
I tried running both of these commands:
npm install pcap --save
// package.json dependency
"pcap": "mranney/node_pcap"
> socketwatcher@0.2.1 install /home/ryan/.nvm/versions/node/v5.4.1/lib/node_modules/pcap/node_modules/socketwatcher
> node-gyp rebuild
make: Entering directory '/home/ryan/.nvm/versions/node/v5.4.1/lib/node_modules/pcap/node_modules/socketwatcher/build'
CXX(target) Release/obj.target/socketwatcher/socket_watcher.o
In file included from ../node_modules/nan/nan_new.h:190:0,
from ../node_modules/nan/nan.h:80,
from ../socket_watcher.hpp:8,
from ../socket_watcher.cpp:5:
../node_modules/nan/nan_implementation_12_inl.h: In static member function ‘static NanIntern::FactoryBase<v8::Signature>::return_t NanIntern::Factory<v8::Signature>::New(NanIntern::Factory<v8::Signature>::FTH, int, NanIntern::Factory<v8::Signature>::FTH*)’:
../node_modules/nan/nan_implementation_12_inl.h:181:76: error: no matching function for call to ‘v8::Signature::New(v8::Isolate*, NanIntern::Factory<v8::Signature>::FTH&, int&, NanIntern::Factory<v8::Signature>::FTH*&)’
return v8::Signature::New(v8::Isolate::GetCurrent(), receiver, argc, argv);
^
In file included from /home/ryan/.node-gyp/5.4.1/include/node/node.h:42:0,
from ../node_modules/nan/nan.h:24,
from ../socket_watcher.hpp:8,
from ../socket_watcher.cpp:5:
/home/ryan/.node-gyp/5.4.1/include/node/v8.h:4674:27: note: candidate: static v8::Local<v8::Signature> v8::Signature::New(v8::Isolate*, v8::Local<v8::FunctionTemplate>)
static Local<Signature> New(
^
/home/ryan/.node-gyp/5.4.1/include/node/v8.h:4674:27: note: candidate expects 2 arguments, 4 provided
In file included from ../socket_watcher.hpp:8:0,
from ../socket_watcher.cpp:5:
../node_modules/nan/nan.h: At global scope:
../node_modules/nan/nan.h:171:25: error: redefinition of ‘template<class T> v8::Local<T> _NanEnsureLocal(v8::Local<T>)’
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
^
../node_modules/nan/nan.h:166:25: note: ‘template<class T> v8::Local<T> _NanEnsureLocal(v8::Handle<T>)’ previously declared here
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Handle<T> val) {
^
../node_modules/nan/nan.h:564:13: error: ‘node::smalloc’ has not been declared
, node::smalloc::FreeCallback callback
^
../node_modules/nan/nan.h:564:35: error: expected ‘,’ or ‘...’ before ‘callback’
, node::smalloc::FreeCallback callback
^
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(char*, size_t, int)’:
../node_modules/nan/nan.h:568:50: error: ‘callback’ was not declared in this scope
v8::Isolate::GetCurrent(), data, length, callback, hint);
^
../node_modules/nan/nan.h:568:60: error: ‘hint’ was not declared in this scope
v8::Isolate::GetCurrent(), data, length, callback, hint);
^
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(const char*, uint32_t)’:
../node_modules/nan/nan.h:575:67: error: no matching function for call to ‘New(v8::Isolate*, const char*&, uint32_t&)’
return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
^
In file included from ../node_modules/nan/nan.h:25:0,
from ../socket_watcher.hpp:8,
from ../socket_watcher.cpp:5:
/home/ryan/.node-gyp/5.4.1/include/node/node_buffer.h:31:40: note: candidate: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, v8::Local<v8::String>, node::encoding) <near match>
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
^
/home/ryan/.node-gyp/5.4.1/include/node/node_buffer.h:31:40: note: conversion of argument 3 would be ill-formed:
In file included from ../socket_watcher.hpp:8:0,
from ../socket_watcher.cpp:5:
../node_modules/nan/nan.h:575:67: error: invalid conversion from ‘uint32_t {aka unsigned int}’ to ‘node::encoding’ [-fpermissive]
return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
^
In file included from ../node_modules/nan/nan.h:25:0,
from ../socket_watcher.hpp:8,
from ../socket_watcher.cpp:5:
/home/ryan/.node-gyp/5.4.1/include/node/node_buffer.h:43:40: note: candidate: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, char*, size_t) <near match>
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
^
/home/ryan/.node-gyp/5.4.1/include/node/node_buffer.h:43:40: note: conversion of argument 2 would be ill-formed:
In file included from ../socket_watcher.hpp:8:0,
from ../socket_watcher.cpp:5:
../node_modules/nan/nan.h:575:67: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
^
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(uint32_t)’:
../node_modules/nan/nan.h:579:29: error: could not convert ‘node::Buffer::New(v8::Isolate::GetCurrent(), ((size_t)size))’ from ‘v8::MaybeLocal<v8::Object>’ to ‘v8::Local<v8::Object>’
return node::Buffer::New(v8::Isolate::GetCurrent(), size);
^
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanBufferUse(char*, uint32_t)’:
../node_modules/nan/nan.h:586:12: error: ‘Use’ is not a member of ‘node::Buffer’
return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
^
socketwatcher.target.mk:90: recipe for target 'Release/obj.target/socketwatcher/socket_watcher.o' failed
make: *** [Release/obj.target/socketwatcher/socket_watcher.o] Error 1
make: Leaving directory '/home/ryan/.nvm/versions/node/v5.4.1/lib/node_modules/pcap/node_modules/socketwatcher/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/ryan/.nvm/versions/node/v5.4.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.2.0-23-generic
gyp ERR! command "/home/ryan/.nvm/versions/node/v5.4.1/bin/node" "/home/ryan/.nvm/versions/node/v5.4.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ryan/.nvm/versions/node/v5.4.1/lib/node_modules/pcap/node_modules/socketwatcher
gyp ERR! node -v v5.4.1
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok
/home/ryan/.nvm/versions/node/v5.4.1/lib
└── (empty)
npm ERR! Linux 4.2.0-23-generic
npm ERR! argv "/home/ryan/.nvm/versions/node/v5.4.1/bin/node" "/home/ryan/.nvm/versions/node/v5.4.1/bin/npm" "install" "-g" "pcap"
npm ERR! node v5.4.1
npm ERR! npm v3.5.3
npm ERR! code ELIFECYCLE
npm ERR! socketwatcher@0.2.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the socketwatcher@0.2.1 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the socketwatcher package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs socketwatcher
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls socketwatcher
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/ryan/Code/pguests/npm-debug.log
npm ERR! code 1
The error is caused by node-gyp trying to build a non-existing dependency socketwatcher@0.2.1
, which isn't listed as an available version by npm view socketwatcher
( available versions: 0.1.0, 0.1.1, 0.1.2, 0.2.0, 0.3.0
).
I'm eager to try out this library; are there any workarounds I can use to get around this install problem?
Environment:
- node v5.3.1
- npm v3.5.3
- Linux 4.2.0-23-generic (Ubuntu 15.10)
Attached:
Also failed on node v4.2.4, npm v2.14.12, Ubuntu 14.04.3 LTS
I'm digging deeper into socketwatcher. Could be related to #70 or btrask/node-socketwatcher#8.
Looks like commit 29737ce moved socketwatcher from a forked-fork (https://github.com/zerouid/node-socketwatcher) which is where the 0.2.1 came from.
The weirdest part is that it feels like this all worked last week...
This feels like a duplicate of #192. @rgrannell1, do you agree?
Yes @ecaron, it seems to be the same issue; I would have commented under that issue but I had only read the post, not responses to it.
Just to note, the workaround suggested of using:
npm install https://github.com/mranney/node_pcap.git
fails with the following error:
ryan@ryan-S400CA:~/Code/pguests$ npm install https://github.com/mranney/node_pcap.git
> socketwatcher@0.3.0 install /home/ryan/Code/pguests/node_modules/socketwatcher
> node-gyp rebuild
make: Entering directory '/home/ryan/Code/pguests/node_modules/socketwatcher/build'
CXX(target) Release/obj.target/socketwatcher/socket_watcher.o
SOLINK_MODULE(target) Release/obj.target/socketwatcher.node
COPY Release/socketwatcher.node
make: Leaving directory '/home/ryan/Code/pguests/node_modules/socketwatcher/build'
> pcap@2.0.0 install /home/ryan/Code/pguests/node_modules/pcap
> node-gyp rebuild
make: Entering directory '/home/ryan/Code/pguests/node_modules/pcap/build'
CXX(target) Release/obj.target/pcap_binding/pcap_binding.o
../pcap_binding.cc:2:23: fatal error: pcap/pcap.h: No such file or directory
compilation terminated.
pcap_binding.target.mk:91: recipe for target 'Release/obj.target/pcap_binding/pcap_binding.o' failed
make: *** [Release/obj.target/pcap_binding/pcap_binding.o] Error 1
make: Leaving directory '/home/ryan/Code/pguests/node_modules/pcap/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/ryan/.nvm/versions/node/v5.4.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.2.0-23-generic
gyp ERR! command "/home/ryan/.nvm/versions/node/v5.4.1/bin/node" "/home/ryan/.nvm/versions/node/v5.4.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ryan/Code/pguests/node_modules/pcap
gyp ERR! node -v v5.4.1
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok
pguests@1.0.0 /home/ryan/Code/pguests
└── socketwatcher@0.3.0 extraneous
npm WARN enoent ENOENT: no such file or directory, open '/home/ryan/Code/pguests/node_modules/pguests/package.json'
npm ERR! Linux 4.2.0-23-generic
npm ERR! argv "/home/ryan/.nvm/versions/node/v5.4.1/bin/node" "/home/ryan/.nvm/versions/node/v5.4.1/bin/npm" "install" "https://github.com/mranney/node_pcap.git"
npm ERR! node v5.4.1
npm ERR! npm v3.5.3
npm ERR! code ELIFECYCLE
npm ERR! pcap@2.0.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pcap@2.0.0 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the pcap package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs pcap
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls pcap
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/ryan/Code/pguests/npm-debug.log
The error warns about a missing header file pcap/pcap.h
.
for the pcap.h error install libpcap-dev. Then installing via git works. npm install pcap still fails with various compile errors in socket_watcher.cpp http://pastebin.com/MGvhYkrm
The issue is resolved by this edit that changes socketwatcher dependency url from some branched git (that perhaps resolved a compile issue from the past) back to the central socketwatcher repository:
I have the same issue, did you find solution/workaround?
Currently I updated all my code to whatever format is being used almost recently and I'm installing via the commit hash I linked to. https://github.com/cyphunk/snifferjs/blob/master/package.json#L13 With that npm install
works fine. Tested with ubuntu 14.04 lts, node 4.2.6 lts npm 2.14.12 node-gyp 3.0.3
This is what worked for me as a full install (including nodejs):
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe"
sudo dpkg --configure -a && sudo apt-get update && sudo apt-get -y upgrade
sudo aptitude install nodejs
sudo apt-get install libpcap-dev git
npm install https://github.com/mranney/node_pcap.git
I'm on Ubuntu 15.10.
node v4.3.2
npm 2.14.12
Hope it helps someone.
Cheers!
like @cyphunk said,
for the pcap.h error install libpcap-dev. Then installing via git works.
on Arch Linux ,node v 4.4.4 npm 2.15.1
sudo pacman -S libpcap
then
npm install https://github.com/mranney/node_pcap.git
it works,Hope it helps someone
npm install https://github.com/mranney/node_pcap.git
worked for me, I'm on
OS X El Capitan
node v5.7.0
nam 3.6.0
however npm install pcap --save
did not, just an update
fails on mac still.
@chovy Install worked for me with npm install https://github.com/mranney/node_pcap.git
on Mac OS X - you might need C++/Xcode installed to compile the native package. BTW: The npm package was updated 2 years ago, who could publish current master to npm? package.json shows 2.0.0 and npm 2.0.1.
Centos 6.4
node v6.10.0
npm 3.10.0
and
node v4.3.2
npm 2.14.12
after installing libpcap-dev,still don't work!
Why is this still an issue over a year later? Is this project dead?
@killerspaz It appears to be. I wanted to use arpjs, but it has this failed dependency.
Installing libpcap-dev worked for me.
sudo apt-get install libpcap-dev
Hi
Had issues with installing pcap and npm install https://github.com/mranney/node_pcap.git
from @rgrannell1 did it.
ubuntu 16.04.1
node v8.9.2
sudo apt-get install libpcap-dev
npm install https://github.com/mranney/node_pcap.git
works
what about windows?
CentOS 7
yum install libpcap-devel -y
centos 7
yum install libpcap-dev -y
yum install libpcap-devel -y
npm install pcap
what about windows?
git clone git://github.com/mranney/node_pcap.git
cd node_pcap
download WpdPack_4_1_2 and extract it in node_pcap
copy WpdPack\Include and WpdPack\Lib folder to node_pcap
change bindings.gyp as below
{
"targets": [
{
"target_name": "pcap_binding",
"sources": [ "pcap_binding.cc", "pcap_session.cc" ],
"include_dirs": [
"Include",
"Lib",
"<!(node -e "require('nan')")"
],
"link_settings": {
"libraries": [
"-l../lib/x64/wpcap"
,"-l../lib/x64/Packet"
,"-lWs2_32"
]
},
'configurations': {
'Release': {
'msvs_settings': {
'VCCLCompilerTool': {
'ExceptionHandling': 2
}
}
}
},
}
]
}
modify pcap_session.cc like below;
mark lines as comment from 212 to 220
// fixes a previous to-do that was here.
//if (info.Length() == 6) {
// if (info[5]->Int32Value()) {
// if (pcap_set_rfmon(session->pcap_handle, 1) != 0) {
// Nan::ThrowError(pcap_geterr(session->pcap_handle));
// return;
// }
// }
//}
change include part, I dont remember some header file as below.
add #include <conio.h>
change line number 343 as below
//int fd = pcap_get_selectable_fd(session->pcap_handle);
int fd = pcap_fileno(session->pcap_handle);
chane line number 405 as below
if (pcap_sendpacket(session->pcap_handle, (u_char *)bufferData, bufferLength) != (int)bufferLength) {
finally
cd node_pcap
node-gyp configure build -arch=x64
node-gyp install
C:\DEV\CaptureJS\node_pcap>node-gyp configure build -arch=x64
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@8.11.1 | win32 | x64
gyp info spawn c:\python27\python.EXE
gyp info spawn args [ 'C:\Users\baris\AppData\Roaming\npm\node_modules\node-gyp\gyp\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-G',
gyp info spawn args 'msvs_version=2015',
gyp info spawn args '-I',
gyp info spawn args 'C:\DEV\CaptureJS\node_pcap\build\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\baris\AppData\Roaming\npm\node_modules\node-gyp\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\baris\.node-gyp\8.11.1\include\node\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\Users\baris\.node-gyp\8.11.1',
gyp info spawn args '-Dnode_gyp_dir=C:\Users\baris\AppData\Roaming\npm\node_modules\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\Users\baris\.node-gyp\8.11.1\<(target_arch)\node.lib',
gyp info spawn args '-Dmodule_root_dir=C:\DEV\CaptureJS\node_pcap',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'C:\DEV\CaptureJS\node_pcap\build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
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
c:\dev\capturejs\node_pcap\pcap_session.cc(85): warning C4996: 'Nan::MakeCallback': was declared deprecated [C:\DEV\CaptureJS\node_pcap\build\pcap_binding.vcxproj]
c:\dev\capturejs\node_pcap\node_modules\nan\nan.h(959): note: see declaration of 'Nan::MakeCallback'
Creating library C:\DEV\CaptureJS\node_pcap\build\Release\pcap_binding.lib and object C:\DEV\CaptureJS\node_pcap\build\Release\pcap_binding.exp
Generating code
Finished generating code
pcap_binding.vcxproj -> C:\DEV\CaptureJS\node_pcap\build\Release\pcap_binding.node
gyp info ok
C:\DEV\CaptureJS\node_pcap>node-gyp install
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@8.11.1 | win32 | x64
gyp http GET https://nodejs.org/download/release/v8.11.1/node-v8.11.1-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v8.11.1/node-v8.11.1-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v8.11.1/SHASUMS256.txt
gyp http GET https://nodejs.org/download/release/v8.11.1/win-x64/node.lib
gyp http GET https://nodejs.org/download/release/v8.11.1/win-x86/node.lib
gyp http 200 https://nodejs.org/download/release/v8.11.1/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v8.11.1/win-x64/node.lib
gyp http 200 https://nodejs.org/download/release/v8.11.1/win-x86/node.lib
8.11.1
gyp info ok
C:\DEV\CaptureJS\node_pcap>
but it doesn't work.
windows is definitely not supported for now, see #249 (comment). this should be closed