node_pcap: `npm install pcap` fails (node v5.4.1, npm 3.5.3)

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:

npm-debug.txt

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 8
  • Comments: 24 (1 by maintainers)

Most upvoted comments

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

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!

what about windows?

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.

Installing libpcap-dev worked for me.

sudo apt-get install libpcap-dev

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:

https://github.com/mranney/node_pcap/commit/29737ced5e50c8ed40f847abeb826e45c796a852

ubuntu 16.04.1 node v8.9.2 sudo apt-get install libpcap-dev npm install https://github.com/mranney/node_pcap.git

works

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!

fails on mac still.