trying to 'npm install', getting node-gyp rebuild errors

ernestscomputer:musicomp ernest son$ npm install

><EMAIL_ADDRESS>install /Users/ernest son/Desktop/PROJECTS/musicomp/node_modules/bufferutil
> node-gyp rebuild

  CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/include/node'
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/src'
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/deps/uv/include'
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/deps/v8/include'
make: *** [Release/obj.target/bufferutil/src/bufferutil.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270: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 Darwin 14.5.0
gyp ERR! command "/usr/local/Cellar/node/5.0.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/ernest son/Desktop/PROJECTS/musicomp/node_modules/bufferutil
gyp ERR! node -v v5.0.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN<EMAIL_ADDRESS><EMAIL_ADDRESS>install: `node-gyp rebuild`
npm WARN<EMAIL_ADDRESS>Exit status 1

><EMAIL_ADDRESS>install /Users/ernest son/Desktop/PROJECTS/musicomp/node_modules/utf-8-validate
> node-gyp rebuild

  CXX(target) Release/obj.target/validation/src/validation.o
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/include/node'
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/src'
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/deps/uv/include'
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/deps/v8/include'
make: *** [Release/obj.target/validation/src/validation.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270: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 Darwin 14.5.0
gyp ERR! command "/usr/local/Cellar/node/5.0.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/ernest son/Desktop/PROJECTS/musicomp/node_modules/utf-8-validate
gyp ERR! node -v v5.0.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN<EMAIL_ADDRESS><EMAIL_ADDRESS>install: `node-gyp rebuild`
npm WARN<EMAIL_ADDRESS>Exit status 1

back story:  in trying to uninstall iojs and reinstall node, I entered a world of shizzao but finally got node and npm installed successfully....I tried installing node-gyp globally to no avail...

Delete your $HOME/.node-gyp directory and try again.
Aside, many tools don't handle spaces in path names well (/Users/ernest son/...).

sorry, when you say "$home" do you essentially mean usr/local/bin?  that's what "which node-gyp" yields in term...or do you mean another location?
I did change my user name but eliminating space for "_".  thanks for the heads up

I mean the HOME environment variable. :-)  node-gyp normally downloads the development tarballs to $HOME/.node-gyp, i.e., /home/username/.node-gyp or /Users/username/.node-gyp.

thanks, i figured out what you meant....just tried npm install and it appears i still have rebuild issues.  it looks as though my user rename didn't propogate..(?)
><EMAIL_ADDRESS>install /Users/ernest son/Desktop/PROJECTS/musicomp/node_modules/bufferutil
> node-gyp rebuild

  CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/include/node'
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/src'
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/deps/uv/include'
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/deps/v8/include'
make: *** [Release/obj.target/bufferutil/src/bufferutil.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270: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 Darwin 14.5.0
gyp ERR! command "/usr/local/Cellar/node/5.0.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/ernest son/Desktop/PROJECTS/musicomp/node_modules/bufferutil
gyp ERR! node -v v5.0.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN<EMAIL_ADDRESS><EMAIL_ADDRESS>install: `node-gyp rebuild`
npm WARN<EMAIL_ADDRESS>Exit status 1

><EMAIL_ADDRESS>install /Users/ernest son/Desktop/PROJECTS/musicomp/node_modules/utf-8-validate
> node-gyp rebuild

  CXX(target) Release/obj.target/validation/src/validation.o
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/include/node'
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/src'
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/deps/uv/include'
clang: error: no such file or directory: 'son/.node-gyp/5.0.0/deps/v8/include'
make: *** [Release/obj.target/validation/src/validation.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270: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!   It's also possible that $HOME/.npmrc has some outdated variables.

so redelete $HOME/.node-gyp and also .npmrc?

Maybe just edit your .npmrc in case it contains valuable things like tokens.

i see a .rvmrc folder in $HOME, but no .npmrc.....and how exactly would I edit it (if I could find it)?

If you don't have a .npmrc, don't worry about it.  If you do, just vim will do; it's a text file.

I don't have one...any other ideas? I think I've tried everything on our
list
On Mon, Nov 9, 2015 at 1:39 PM Ben Noordhuis<EMAIL_ADDRESS>wrote:

If you don't have a .npmrc, don't worry about it. If you do, just vim will
do; it's a text file.
—
Reply to this email directly or view it on GitHub
https://github.com/nodejs/node-gyp/issues/809#issuecomment-155150352.

getting same problem here when trying to install ember-cli

same problem here with contextify.

for me, the solution was fixing the space in my home folder (that was a whole other "can o' worms").  then 'npm install' worked like a charm. also, I suggest reaching out to the folks at npm if it truly is npm related.  They're great!

I also had the node-gyp rebuild error while installing utf-8-validate package through npm. Removing the space from my filepath also worked for me.

Same with botkit. https://github.com/howdyai/botkit/issues/2

Ok, so I do not have a space in my filepath. I deleted the ~/.node-gyp folder and then the ~/.npmrc file. Restarted my computer. Then tried again and it worked. Hope that helps someone else out there!

@aroc It doesn't helped for me :(

Thanks @bnoordhuis! I had the same issue with no spaces in my file path. Deleting the original node_modules folder from my project, then deleting .node-gyp (I did not have .npmrc), restarting, and installing node in my project again with (sudo npm install) worked with no errors.
Node v5.2.0

Yikes. It scares me to think how low-level this is that a machine restart is a potential solution...

I had similar issues on Ubuntu 14.04, after trying everything here I finally solved it by running:
sudo apt-get install build-essential
As is recommended here: https://nodejs.org/en/download/package-manager/

I already had build-essential installed, installing the following did the trick for me:
apt-get install libkrb5-dev

For me, just deleting the ~/.node-gyp folder, then running npm update on my project solved the problem (without rebooting). Thank for the trick!

Run into same error when trying to download dependencies for angular-phonecat . I solved it by using @bnoordhuis  method just the same way @JxnGraphix put it.
Node 4.2.3

I also deleted the node_modules directory I had (including .node-gyp and all), solved my isse.

Thanks @aroc I removed ~/.node-gyp and ~/.npmrc. In my project I removed node_modules and restarted my machine (restart might not be necessary) and all worked great.
node v4.1.2
npm 2.14.4
OS X El Capitan

Thanks @aroc I removed ~/.node-gyp and ~/.npmrc. In my project I removed node_modules and restarted my machine (restart might not be necessary) and all worked great.
node v4.1.2
npm 2.14.4
OS X El Capitan

Thanks @JxnGraphix - your solution worked for me

for me helped:
apt-get install libkrb5-dev

Had a problem with this rebuilding node-sass, deleting ~/.node-gyp and npm update did it for me.

Closing, looks like this issue ran its course.

Running node 6.2.0 here and getting getting node-gyp error. Anyone had this issue with this version of node.js ?

@novarac23 I'm getting it with node 6.1.0

Same here, node v6.2.1

Here as well, node v6.2.1

Yes same here also... node v6.2.1 with Windows OS

To solve this I downgraded node to v5.12.0, removed ~/.node-gyp folder and reinstalled node modules.

presleguine solution worked for me but  downgrading the node to  v4.4.7

We're using node v4.4.7. Presliguine's solution did not work. We're receiving the '__pfnDliNotifyHook2 error.

I tried many suggestions and the only thing that worked is @JxnGraphix solution. Steps are:

Delete .node-gyp from root
Go to project directory then delete node_modules folder
sudo npm install

Finally.... Wew!

Dang it I just don't have luck with Node these days.
I tried to downgrade the version to 4.x.x and removed node-gyp and removed node-modules from the project and still nothing... 😢

Working on RHEL6 here.
Same problem with v6.2.1
Everything goes again smoothly when downgrading to v5.12.0 (I use nvm for simplicity)

If you don't have a space in your username then you're probably not experiencing the same problem as the original poster. If you're getting compile failures it could be because of your build environment setup or the package that you're trying to install has some problem with the version of Node.js you're using. If you still think it's a node-gyp problem then please paste your full output to a gist or similar and give us the URL so we can see if there's anything to be gleaned from it.

I can confirm that the the issue lies with Windows. I might have the wrong version of Visual Studio installed on my pc, but I wasn't able to rebuild the s2geometry part.
On Ubuntu 16.0 I had no problem installing the API on a fresh NodeJs install. So to use this API on Windows, you need a Virtual System running Linux to develop in.

<EMAIL_ADDRESS>install /Users/chadsfather/Desktop/All Your Desktop Groups Files/Escritorio/proyectos_web/pokeradar/testpk/node_modules/s2geometry-node
node-gyp rebuild

CXX(target) Release/obj.target/NativeExtension/src/NativeExtension.o
c++: error: unrecognized command line option '-stdlib=libc++'
make: *** [Release/obj.target/NativeExtension/src/NativeExtension.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Darwin 15.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/chadsfather/Desktop/All Your Desktop Groups Files/Escritorio/proyectos_web/pokeradar/testpk/node_modules/s2geometry-node
gyp ERR! node -v v6.2.2
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm WARN<EMAIL_ADDRESS>No repository field.
npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v6.2.2
npm ERR! npm  v3.8.3
npm ERR! code ELIFECYCLE
npm ERR<EMAIL_ADDRESS>install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the<EMAIL_ADDRESS>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 s2geometry-node 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 s2geometry-node
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls s2geometry-node
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR!     /Users/chadsfather/Desktop/All Your Desktop Groups Files/Escritorio/proyectos_web/pokeradar/testpk/npm-debug.log
OS X El Capitan
node v6.2.2
npm 3.8.3

Just parroting the issue : I've had two completely separate applications fail to build in the last week, apparently due to node-gyp rebuild. One is a meteor app, running on win7, the other is on an ubuntu box - a mature application, suddenly breaking. I get very similar output to the above, due to two separate, and unrelated, parent packages (bcrypt and contextify).
Sample output :
make: Leaving directory `/users/jbosworth/fusion-dgo/node_modules/jsdom/node_modules/contextify/build'
make: *** [Release/obj.target/contextify/src/contextify.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/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 3.13.0-63-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /users/jbosworth/fusion-dgo/node_modules/jsdom/node_modules/contextify
gyp ERR! node -v v4.4.4
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm ERR! Linux 3.13.0-63-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v4.4.4
npm ERR! npm  v2.15.1
npm ERR! code ELIFECYCLE

npm ERR<EMAIL_ADDRESS>install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the<EMAIL_ADDRESS>install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the contextify 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 contextify
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls contextify
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /users/jbosworth/fusion-dgo/npm-debug.log

Current versions of node / npm
Have not found a solution, yet.

+1 to this issue. I've tried all of the above, downgraded from 6 > 5, then 5 > 4 using n with no luck.
npm-debug.log snippet
1290 verbose stack Error<EMAIL_ADDRESS>install: `node-pre-gyp install --fallback-to-build`
1290 verbose stack Exit status 1
1290 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:239:16)
1290 verbose stack     at emitTwo (events.js:100:13)
1290 verbose stack     at EventEmitter.emit (events.js:185:7)
1290 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14)
1290 verbose stack     at emitTwo (events.js:100:13)
1290 verbose stack     at ChildProcess.emit (events.js:185:7)
1290 verbose stack     at maybeClose (internal/child_process.js:850:16)
1290 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
1291 verbose pkgid<EMAIL_ADDRESS>1292 verbose cwd /home/drew/code/mean/app
1293 error Linux 4.4.0-31-generic
1294 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
1295 error node v5.12.0
1296 error npm  v3.8.6
1297 error code ELIFECYCLE
1298 error<EMAIL_ADDRESS>install: `node-pre-gyp install --fallback-to-build`
1298 error Exit status 1
1299 error Failed at the<EMAIL_ADDRESS>install script 'node-pre-gyp install --fallback-to-build'.
1299 error Make sure you have the latest version of node.js and npm installed.
1299 error If you do, this is most likely a problem with the v8-debug package,
1299 error not with npm itself.
1299 error Tell the author that this fails on your system:
1299 error     node-pre-gyp install --fallback-to-build
1299 error You can get information on how to open an issue for this project with:
1299 error     npm bugs v8-debug
1299 error Or if that isn't available, you can get their info via:
1299 error     npm owner ls v8-debug
1299 error There is likely additional logging output above.
1300 verbose exit [ 1, true ]

@Bosworth99 @drewsmith You are omitting the actual build error.

@bnoordhuis - I believe this should be more helpfull :
><EMAIL_ADDRESS>install /users/jbosworth/fusion-dgo/node_modules/jsdom/node_modules/contextify
> node-gyp rebuild

make: Entering directory `/users/jbosworth/fusion-dgo/node_modules/jsdom/node_modules/contextify/build'
  CXX(target) Release/obj.target/contextify/src/contextify.o
In file included from ../node_modules/nan/nan_new.h:181:0,
                 from ../node_modules/nan/nan.h:74,
                 from ../src/contextify.cc:3:
../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:172: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);
                                                                            ^
../node_modules/nan/nan_implementation_12_inl.h:172:76: note: candidate is:
In file included from /users/jbosworth/.node-gyp/4.4.4/include/node/node.h:42:0,
                 from ../src/contextify.cc:1:
/users/jbosworth/.node-gyp/4.4.4/include/node/v8.h:4675:27: note: static v8::Local<v8::Signature> v8::Signature::New(v8::Isolate*, v8::Local<v8::FunctionTemplate>)
   static Local<Signature> New(
                           ^
/users/jbosworth/.node-gyp/4.4.4/include/node/v8.h:4675:27: note:   candidate expects 2 arguments, 4 provided
In file included from ../src/contextify.cc:3:0:
../node_modules/nan/nan.h: At global scope:
../node_modules/nan/nan.h:165: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:160:25: error: ‘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:500:13: error: ‘node::smalloc’ has not been declared
     , node::smalloc::FreeCallback callback
             ^
../node_modules/nan/nan.h:500: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:504:50: error: ‘callback’ was not declared in this scope
         v8::Isolate::GetCurrent(), data, length, callback, hint);
                                                  ^
../node_modules/nan/nan.h:504: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:511:67: error: call of overloaded ‘New(v8::Isolate*, const char*&, uint32_t&)’ is ambiguous
     return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
                                                                   ^
../node_modules/nan/nan.h:511:67: note: candidates are:
In file included from ../node_modules/nan/nan.h:25:0,
                 from ../src/contextify.cc:3:
/users/jbosworth/.node-gyp/4.4.4/include/node/node_buffer.h:31:40: note: 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,
                                        ^
/users/jbosworth/.node-gyp/4.4.4/include/node/node_buffer.h:31:40: note:   no known conversion for argument 3 from ‘uint32_t {aka unsigned int}’ to ‘node::encoding’
/users/jbosworth/.node-gyp/4.4.4/include/node/node_buffer.h:43:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, char*, size_t) <near match>
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                        ^
/users/jbosworth/.node-gyp/4.4.4/include/node/node_buffer.h:43:40: note:   no known conversion for argument 2 from ‘const char*’ to ‘char*’
In file included from ../src/contextify.cc:3:0:
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(uint32_t)’:
../node_modules/nan/nan.h:515:61: 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:522:12: error: ‘Use’ is not a member of ‘node::Buffer’
     return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
            ^
make: *** [Release/obj.target/contextify/src/contextify.o] Error 1
make: Leaving directory `/users/jbosworth/fusion-dgo/node_modules/jsdom/node_modules/contextify/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/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 3.13.0-63-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /users/jbosworth/fusion-dgo/node_modules/jsdom/node_modules/contextify
gyp ERR! node -v v4.4.4
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm ERR! Linux 3.13.0-63-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v4.4.4
npm ERR! npm  v2.15.1
npm ERR! code ELIFECYCLE

npm ERR<EMAIL_ADDRESS>install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the<EMAIL_ADDRESS>install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the contextify 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 contextify
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls contextify
npm ERR! There is likely additional logging output above.

This is a ubuntu box,
node v4.4.4
npm v2.15.1
Having a very similar issue with the Bcrypt package on a win7 box:
node v6.3.0
npm 3.10.3
Thanks for looking into this.

@Bosworth99 That is not a node-gyp issue.  The build errors indicate that the module doesn't support node.js v4.  Try upgrading to the latest contextify release.

@bnoordhuis  - thats a good tip. Will work on it.
Thanks for the quick response -

gyp: binding.gyp not found (cwd: C:\Users\computer_name) while trying to load binding.gyp
I am getting this error

Anyone still facing this issue, this might help (at least worked for me, macbook pro, 10.9.5): http://stackoverflow.com/questions/21752172/invalid-deployment-target-for-stdlib-libc-on-osx-10-8

https://github.com/nodejs/node/issues/8939

Thanks @JxnGraphix, your solution worked for me!

I had the same issue. The problem was in the user's folder name, that was in Cyrillic. I created new profile and followed this instructions https://github.com/nodejs/node-gyp. It helped me

I solved it when I realized that I had an apt-get installed version of nodejs and nvm / npm installed node. Removed the system installed version and created a soft link from nodejs to node and it worked.

I got the same error and I solved by running below:
sudo npm install -g<EMAIL_ADDRESS>Nodejs - v7.2.0
Npm - 4.0.3

Had the same issue and nothing would work. Finally had to go to node 0.10.26 on the pi.
Used NVM instead of direct node install.

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
nvm install 0.10.26

On Windows 10 ubuntu bash, installing build-essential using apt-get install build-essential and rerunning npm install solves the problem

I was able to reproduce this problem on OSX 10.11.6 when building a project that had a dependency of "java": "^0.6.0" changing that to "java": ">=0.6.0" worked fine after
installing Java 7 and/or Java 8 SDK.

I have a similar problem, Please tell me, Is this a problem with the node version or or something else?
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
make: Entering directory /var/www/simple-comm-client.local/fe/node_modules/protractor/node_modules/selenium-webdriver/node_modules/ws/node_modules/utf-8-validate/build'   CXX(target) Release/obj.target/validation/src/validation.o In file included from ../src/validation.cc:15:0: ../node_modules/nan/nan.h:261: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:256:25: error: ‘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:661:13: error: ‘node::smalloc’ has not been declared      , node::smalloc::FreeCallback callback              ^ ../node_modules/nan/nan.h:661: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:665:50: error: ‘callback’ was not declared in this scope          v8::Isolate::GetCurrent(), data, length, callback, hint);                                                   ^ ../node_modules/nan/nan.h:665: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:672:67: error: call of overloaded ‘New(v8::Isolate*, const char*&, uint32_t&)’ is ambiguous      return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);                                                                    ^ ../node_modules/nan/nan.h:672:67: note: candidates are: In file included from ../src/validation.cc:10:0: /home/zhenya/.node-gyp/4.6.1/include/node/node_buffer.h:34:40: note: 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/zhenya/.node-gyp/4.6.1/include/node/node_buffer.h:34:40: note:   no known conversion for argument 3 from ‘uint32_t {aka unsigned int}’ to ‘node::encoding’ /home/zhenya/.node-gyp/4.6.1/include/node/node_buffer.h:46:40: note: 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/zhenya/.node-gyp/4.6.1/include/node/node_buffer.h:46:40: note:   no known conversion for argument 2 from ‘const char*’ to ‘char*’ In file included from ../src/validation.cc:15:0: ../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(uint32_t)’: ../node_modules/nan/nan.h:676:61: 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:683:12: error: ‘Use’ is not a member of ‘node::Buffer’      return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);             ^ make: *** [Release/obj.target/validation/src/validation.o] Error 1 make: Leaving directory /var/www/simple-comm-client.local/fe/node_modules/protractor/node_modules/selenium-webdriver/node_modules/ws/node_modules/utf-8-validate/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/zhenya/.nvm/versions/node/v4.6.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 3.13.0-101-generic
gyp ERR! command "/home/zhenya/.nvm/versions/node/v4.6.1/bin/node" "/home/zhenya/.nvm/versions/node/v4.6.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/simple-comm-client.local/fe/node_modules/protractor/node_modules/selenium-webdriver/node_modules/ws/node_modules/utf-8-validate
gyp ERR! node -v v4.6.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok

<EMAIL_ADDRESS>install /var/www/simple-comm-client.local/fe/node_modules/protractor/node_modules/selenium-webdriver/node_modules/ws/node_modules/bufferutil
node-gyp rebuild

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
make: Entering directory /var/www/simple-comm-client.local/fe/node_modules/protractor/node_modules/selenium-webdriver/node_modules/ws/node_modules/bufferutil/build'   CXX(target) Release/obj.target/bufferutil/src/bufferutil.o In file included from ../src/bufferutil.cc:16:0: ../node_modules/nan/nan.h:261: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:256:25: error: ‘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:661:13: error: ‘node::smalloc’ has not been declared      , node::smalloc::FreeCallback callback              ^ ../node_modules/nan/nan.h:661: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:665:50: error: ‘callback’ was not declared in this scope          v8::Isolate::GetCurrent(), data, length, callback, hint);                                                   ^ ../node_modules/nan/nan.h:665: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:672:67: error: call of overloaded ‘New(v8::Isolate*, const char*&, uint32_t&)’ is ambiguous      return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);                                                                    ^ ../node_modules/nan/nan.h:672:67: note: candidates are: In file included from ../src/bufferutil.cc:10:0: /home/zhenya/.node-gyp/4.6.1/include/node/node_buffer.h:34:40: note: 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/zhenya/.node-gyp/4.6.1/include/node/node_buffer.h:34:40: note:   no known conversion for argument 3 from ‘uint32_t {aka unsigned int}’ to ‘node::encoding’ /home/zhenya/.node-gyp/4.6.1/include/node/node_buffer.h:46:40: note: 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/zhenya/.node-gyp/4.6.1/include/node/node_buffer.h:46:40: note:   no known conversion for argument 2 from ‘const char*’ to ‘char*’ In file included from ../src/bufferutil.cc:16:0: ../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(uint32_t)’: ../node_modules/nan/nan.h:676:61: 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:683:12: error: ‘Use’ is not a member of ‘node::Buffer’      return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);             ^ make: *** [Release/obj.target/bufferutil/src/bufferutil.o] Error 1 make: Leaving directory /var/www/simple-comm-client.local/fe/node_modules/protractor/node_modules/selenium-webdriver/node_modules/ws/node_modules/bufferutil/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/zhenya/.nvm/versions/node/v4.6.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 3.13.0-101-generic
gyp ERR! command "/home/zhenya/.nvm/versions/node/v4.6.1/bin/node" "/home/zhenya/.nvm/versions/node/v4.6.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/simple-comm-client.local/fe/node_modules/protractor/node_modules/selenium-webdriver/node_modules/ws/node_modules/bufferutil
gyp ERR! node -v v4.6.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN optional dep failed, continuing<EMAIL_ADDRESS>

honestly i didn't read all of the stack traces here but i found in a line of mine, that something did not found the g++ lib. So i installed that and then it works for me.
sudo apt-get install g++
Worked for me

Here's my case what fixed it:
I used nvm and had 7.2.1 installed.

Removed nvm brew uninstall nvm
Surely remove node, sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
Install<EMAIL_ADDRESS>brew install node@6
Errors gone!

MAC USERS. @mrmoss and I figured (part of) this out.
POSIX definitions are different for GCC and Clang.
If you use gcc an it redirects to clang, then you'll have issues with a lot of packages that use node-gyp. You can get around it by installing GCC with homebrew via brew install gcc.

I'm not sure this is the same issue. The errors were fairly straight forward for the terminal package we were using:
  CXX(target) Release/obj.target/termios/src/termios.o
../src/termios.cpp:31:10: error: use of undeclared identifier 'B460800'
{460800, B460800},
         ^
../src/termios.cpp:32:10: error: use of undeclared identifier 'B500000'
{500000, B500000},
         ^
../src/termios.cpp:33:10: error: use of undeclared identifier 'B576000'
{576000, B576000},
         ^
../src/termios.cpp:34:10: error: use of undeclared identifier 'B921600'
{921600, B921600},
         ^
../src/termios.cpp:35:11: error: use of undeclared identifier 'B1000000'
{1000000, B1000000},
          ^
../src/termios.cpp:36:11: error: use of undeclared identifier 'B1152000'
{1152000, B1152000},
          ^
../src/termios.cpp:37:11: error: use of undeclared identifier 'B1500000'
{1500000, B1500000},
          ^
../src/termios.cpp:38:11: error: use of undeclared identifier 'B2000000'
{2000000, B2000000},
          ^
../src/termios.cpp:39:11: error: use of undeclared identifier 'B2500000'
{2500000, B2500000},
          ^
../src/termios.cpp:40:11: error: use of undeclared identifier 'B3000000'
{3000000, B3000000},
          ^
../src/termios.cpp:41:11: error: use of undeclared identifier 'B3500000'
{3500000, B3500000},
          ^
../src/termios.cpp:42:11: error: use of undeclared identifier 'B4000000'
{4000000, B4000000},
          ^
../src/termios.cpp:86:18: error: use of undeclared identifier 'CBAUD'
                        t.c_cflag &= ~CBAUD;
                                      ^
../src/termios.cpp:106:38: error: use of undeclared identifier 'CBAUD'
        int baud = mask_to_baud(t.c_cflag & CBAUD);

Upon searching similar macOS errors, this seems to be a known issue between the macOS and GNU headers.

Any one has idea about this error..
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 2.6.32-642.4.2.el6.x86_64
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/otenro/Otenro/node_modules/lwip
gyp ERR! node -v v6.9.2
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY<EMAIL_ADDRESS>(node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for<EMAIL_ADDRESS>wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! Linux 2.6.32-642.4.2.el6.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "update"
npm ERR! node v6.9.2
npm ERR! npm  v3.10.9
npm ERR! code ELIFECYCLE
npm ERR<EMAIL_ADDRESS>install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the<EMAIL_ADDRESS>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 lwip 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 lwip
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls lwip
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
I removed .node-gyp and npm update but it didnt work.

@madhurangaonbit It's right there in the error message...

Unsupported platform for<EMAIL_ADDRESS>wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

Nope everything is working fine in local machine with below config
node -v
v6.9.2
npm -v
3.10.9
Ubuntu 16.10
Issue  comes up on Cent Os v6+
Any idea??

Looking at what you posted again, I think you omitted the actual build error; fsevents is just a red herring.
My money is on your system's compiler being too old.

same here:
https://github.com/videojs/video.js/issues/3877

This is still an issue for CentOS 6+ @madhurangaonbit I followed the instructions on this SO post and managed to resolved node-gyp:
http://stackoverflow.com/questions/36327805/how-to-install-gcc-5-3-with-yum-on-centos-7-2
Cheers.

@jasonwr thankz

Problem exist with following configuration as well:
node -v: 7.3.0
npm -v: 4.1.1
macOS Sierra
Version 10.12.2

@klemenoslaj Could you open a new issue with information about your actual failure (what you ran, what the errors were). Did you follow the dependency installation instructions in the README?
Also did you upgrade your npm version? node v7.3.0 seems to come with npm v3.10.10 by default.

Updating to gcc 5 fixed this for me.

same here when installing zmq (zero mq) https://github.com/JustinTulloss/zeromq.node/issues/586

Having this issue on a 2013 Macbook air running Latest MacOS. I'm specifically trying to install the dependencies for soundcast : https://github.com/andresgottlieb/soundcast/tree/master/archive

@DavidAwad node-gyp rebuild errors are basically compile errors, and are usually a problem with the package you're trying to compile (if your program doesn't compile, 99% of the time it's not the compiler's fault).
In this case the package you're trying to install has an outdated dependency chromecast-osx-audio v0.2.0, which itself depends on osx-audio v0.2.0. This is broken. Updating to the latest version fixes the issue. Looking at the npm-debug.log (as the error message tells you to do) tells you where the problem occurred, and what to do about it (this is most likely a problem with the osx-audio package, contact the package author etc.).
The package you're trying to install is unmaintained, you'll probably need to at least update the dependencies. Updating chromecast-osx-audio got it to install for me (although you'll probably have other issues getting it to actually run).
diff --git a/archive/package.json b/archive/package.json
index be55cfa..1841dec 100644
--- a/archive/package.json
+++ b/archive/package.json
@@ -8,7 +8,7 @@
     "url": "https://github.com/andresgottlieb/soundcast"
   },
   "dependencies": {
-    "chromecast-osx-audio": "^0.3.0",
+    "chromecast-osx-audio": "^1.0.1",
     "menubar": "2.3.0",
     "shelljs": "0.5.3"
   },

npm-debug.log
22404 verbose stack Error<EMAIL_ADDRESS>install: `node-gyp rebuild`
22404 verbose stack Exit status 1
22404 verbose stack     at EventEmitter.<anonymous> (/Users/gib/.nvm/versions/node/v6.10.0/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
22404 verbose stack     at emitTwo (events.js:106:13)
22404 verbose stack     at EventEmitter.emit (events.js:191:7)
22404 verbose stack     at ChildProcess.<anonymous> (/Users/gib/.nvm/versions/node/v6.10.0/lib/node_modules/npm/lib/utils/spawn.js:40:14)
22404 verbose stack     at emitTwo (events.js:106:13)
22404 verbose stack     at ChildProcess.emit (events.js:191:7)
22404 verbose stack     at maybeClose (internal/child_process.js:877:16)
22404 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
22405 verbose pkgid<EMAIL_ADDRESS>22406 verbose cwd /Users/gib/tmp/soundcast/archive
22407 error Darwin 16.4.0
22408 error argv "/Users/gib/.nvm/versions/node/v6.10.0/bin/node" "/Users/gib/.nvm/versions/node/v6.10.0/bin/npm" "i"
22409 error node v6.10.0
22410 error npm  v3.10.10
22411 error code ELIFECYCLE
22412 error<EMAIL_ADDRESS>install: `node-gyp rebuild`
22412 error Exit status 1
22413 error Failed at the<EMAIL_ADDRESS>install script 'node-gyp rebuild'.
22413 error Make sure you have the latest version of node.js and npm installed.
22413 error If you do, this is most likely a problem with the osx-audio package,
22413 error not with npm itself.
22413 error Tell the author that this fails on your system:
22413 error     node-gyp rebuild
22413 error You can get information on how to open an issue for this project with:
22413 error     npm bugs osx-audio
22413 error Or if that isn't available, you can get their info via:
22413 error     npm owner ls osx-audio

same here when installing zmq (zero mq) JustinTulloss/zeromq.node#586

@lucaszanella looks like an issue with the module.

sorry, i didn't read all of the above, but if your .npmrc has a path to python try removing it and running node-gyp rebuild again, this resolved the issue for me.. this was after i ran npm uninstall -g node-gyp && npm install -g node-gyp && rm -rf .node-gyp/ but i think just removing the path in my .npmrc was all that really mattered.
note: i use nodenv with node v6.9.2 / npm v3.10.9

I don't know why but I found a solution and worked for me every time. Just simply install build-essential
sudo apt-get update
sudo apt-get install build-essential

I don't know why but I found a solution and worked for me every time. Just simply install build-essential

@amrendraw3 yep, that should work. See the node-gyp README:

You will also need to install:

python (v2.7 recommended, v3.x.x is not supported)
make
A proper C/C++ compiler toolchain, like GCC

According to its docs, build-essential contains gcc/g++ and make, so if you also have python 2 on the system as well (I think it comes by default in Ubuntu) then you have all the dependencies node-gyp needs.

Using ubuntu 16.02 I fixed the problem by install node using the method listed under "How to Install Using a PPA", rather than just using apt-get install
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04

Using ubuntu 16.02 I fixed the problem by install node using the method listed under "How to Install Using a PPA", rather than just using apt-get install

Yep, that just adds the ppa, does an apt-get install of nodejs and npm, and then does sudo apt-get install build-essential, giving you node, npm, and the required build tools.

'restify-json-body-parser'  this package created the issue. After removing it, all went well.

Comment from @ByScripts helped me .. thx

Full installation<EMAIL_ADDRESS>on Ubuntu 16:
cd my_app

npm init

apt-get install build-essential
apt-get install gcc
apt-get install pkg-config
apt-get install libcairo2-dev # not sure about it
apt-get install libpng-dev # not sure about it
apt-get install libjpeg-dev # not sure about it
apt-get install libgif-dev # not sure about it
apt-get install g++ gyp

wget https://raw.githubusercontent.com/XadillaX/aliyun-ons/master/binding.gyp

npm install node-gyp

I keep having this error after tyuping in npm install in my project
`><EMAIL_ADDRESS>install C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\bcrypt

node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v57-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for<EMAIL_ADDRESS>and<EMAIL_ADDRESS>(node-v57 ABI) (falling back to source compile with node-gyp)
C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\bcrypt>if not defined npm_config_node_gyp (node "C:\Users\sesan.osanyinbi\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" clean )  else (node "" clean )
C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\bcrypt>if not defined npm_config_node_gyp (node "C:\Users\sesan.osanyinbi\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" configure --fallback-to-build "--module=C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\bcrypt\lib\binding\bcrypt_lib.node" --module_name=bcrypt_lib "--module_path=C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\bcrypt\lib\binding" --python=C:\Users\sesan.osanyinbi.windows-build-tools\python27\python.exe --msvs_version=2015 )  else (node "" configure --fallback-to-build "--module=C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\bcrypt\lib\binding\bcrypt_lib.node" --module_name=bcrypt_lib "--module_path=C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\bcrypt\lib\binding" --python=C:\Users\sesan.osanyinbi.windows-build-tools\python27\python.exe --msvs_version=2015 )
C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\bcrypt>if not defined npm_config_node_gyp (node "C:\Users\sesan.osanyinbi\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" build --fallback-to-build "--module=C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\bcrypt\lib\binding\bcrypt_lib.node" --module_name=bcrypt_lib "--module_path=C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\bcrypt\lib\binding" )  else (node "" build --fallback-to-build "--module=C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\bcrypt\lib\binding\bcrypt_lib.node" --module_name=bcrypt_lib "--module_path=C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\bcrypt\lib\binding" )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
TRACKER : error TRK0005: Failed to locate: "CL.exe". The system cannot find the file specified.   (C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:125:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:897:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
node-pre-gyp ERR! System Windows_NT 10.0.14393
node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\bcrypt
node-pre-gyp ERR! node -v v8.1.2
node-pre-gyp ERR! node-pre-gyp -v v0.6.32
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd build --fallback-to-build --module=C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\sesan.osanyinbi\Documents\My Web Sites\vggdev\node_modules\bcrypt\lib\binding' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR<EMAIL_ADDRESS>install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the<EMAIL_ADDRESS>install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR!      C:\Users\sesan.osanyinbi\AppData\Roaming\npm-cache_logs\2017-06-28T14_25_05_844Z-debug.log`

macOS High Sierra. Problem has appeared on two computers.
Deleted yarn.lock and package-lock.json (not sure that it's necessary)
Deleted /Users/<username>/.atom/.node-gyp then yarn install and at least I am able to run yarn install without errors. Still erroring when yarn add packages.
P.S. You can locate your .node-gyp files with this command find / -name '.node-gyp' 2>/dev/null

My problem started off as a problem with me not having some MySQL library installed, but now I face this:
npm ERR<EMAIL_ADDRESS>install: `node-gyp rebuild`
npm ERR! Exit status 1

The background:
using<EMAIL_ADDRESS>using<EMAIL_ADDRESS>Running on AWS with Amazon Linux, which is an offshoot of RedHat.
I'm working for a client who has set me up with an EC2 instance where I should do some work. I'd been building an API locally, and now I transferred it to the EC2 instance. I ssh to the server and cd to the directory. I try this:
npm install mysql-libmysqlclient

Initially I got an error about "mysql_config" not being installed. This EC2 instance does not run MySQL and does not have it installed. So I sudo and:
 yum install mysql

That didn't fix the problem, so I kept adding more stuff:
 yum install mysql mysql-server

At some point I got the error "Can't install 'mysql.h' file not found" so I kept adding stuff:
 yum install libmysqlclient-dev
 yum install mysql-devel.noarch   mysql-libs.noarch   mysql-common.noarch
 yum install -y mysql-devel

Some of the errors seem to do with node-gyp, however, if I do this:
 npm install -g node-gyp

then this installs without a problem.
And yet, if I run npm install mysql-libmysqlclient the make output seems to die with a message about node-gyp:
><EMAIL_ADDRESS>install /home/ec2-user/daemons/deduplication_api/v11/dupe-res/node_modules/mysql-libmysqlclient
> node-gyp rebuild

make: Entering directory `/home/ec2-user/daemons/deduplication_api/v11/dupe-res/node_modules/mysql-libmysqlclient/build'
  CXX(target) Release/obj.target/mysql_bindings/src/mysql_bindings.o
In file included from ../src/././mysql_bindings.h:14:0,
                 from ../src/./mysql_bindings_connection.h:22,
                 from ../src/mysql_bindings.cc:17:
../../nan/nan.h: In function ‘v8::Handle<v8::Value> NanError(const char*)’:
../../nan/nan.h:319:38: error: ‘New’ is not a member of ‘v8::String’
 # define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
                                      ^
../../nan/nan.h:339:13: note: in expansion of macro ‘_NAN_ERROR’
     return  _NAN_ERROR(v8::Exception::Error, errmsg);
             ^
../../nan/nan.h: In function ‘void NanThrowError(const char*)’:
../../nan/nan.h:324:7: error: ‘ThrowException’ is not a member of ‘v8’
       v8::ThrowException(_NAN_ERROR(fun, errmsg));                             \
       ^
../../nan/nan.h:343:5: note: in expansion of macro ‘_NAN_THROW_ERROR’
     _NAN_THROW_ERROR(v8::Exception::Error, errmsg);
     ^
../../nan/nan.h:319:38: error: ‘New’ is not a member of ‘v8::String’
 # define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
                                      ^
../../nan/nan.h:324:26: note: in expansion of macro ‘_NAN_ERROR’
       v8::ThrowException(_NAN_ERROR(fun, errmsg));                             \
                          ^
../../nan/nan.h:343:5: note: in expansion of macro ‘_NAN_THROW_ERROR’
     _NAN_THROW_ERROR(v8::Exception::Error, errmsg);
     ^
../../nan/nan.h: In function ‘void NanThrowError(v8::Handle<v8::Value>)’:
../../nan/nan.h:348:5: error: ‘ThrowException’ is not a member of ‘v8’
     v8::ThrowException(error);
     ^
../../nan/nan.h: In function ‘v8::Handle<v8::Value> NanError(const char*, int)’:
../../nan/nan.h:355:53: error: ‘New’ is not a member of ‘v8::String’
     v8::Local<v8::Value> err = v8::Exception::Error(v8::String::New(msg));
                                                     ^
../../nan/nan.h:357:14: error: ‘New’ is not a member of ‘v8::String’
     obj->Set(v8::String::New("code"), v8::Int32::New(errorNumber));
              ^
../../nan/nan.h:357:65: error: no matching function for call to ‘v8::Int32::New(const int&)’
     obj->Set(v8::String::New("code"), v8::Int32::New(errorNumber));
                                                                 ^
../../nan/nan.h:357:65: note: candidate is:
In file included from /home/ec2-user/.node-gyp/6.9.3/include/node/node.h:42:0,
                 from ../src/mysql_bindings.cc:12:
/home/ec2-user/.node-gyp/6.9.3/include/node/v8.h:2558:25: note: static v8::Local<v8::Integer> v8::Integer::New(v8::Isolate*, int32_t)
   static Local<Integer> New(Isolate* isolate, int32_t value);
                         ^
/home/ec2-user/.node-gyp/6.9.3/include/node/v8.h:2558:25: note:   candidate expects 2 arguments, 1 provided
In file included from ../src/././mysql_bindings.h:14:0,
                 from ../src/./mysql_bindings_connection.h:22,
                 from ../src/mysql_bindings.cc:17:
../../nan/nan.h: In function ‘v8::Handle<v8::Value> NanTypeError(const char*)’:
../../nan/nan.h:319:38: error: ‘New’ is not a member of ‘v8::String’
 # define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
                                      ^
../../nan/nan.h:369:12: note: in expansion of macro ‘_NAN_ERROR’
     return _NAN_ERROR(v8::Exception::TypeError, errmsg);
            ^
../../nan/nan.h: In function ‘void NanThrowTypeError(const char*)’:
../../nan/nan.h:324:7: error: ‘ThrowException’ is not a member of ‘v8’
       v8::ThrowException(_NAN_ERROR(fun, errmsg));                             \
       ^
../../nan/nan.h:373:5: note: in expansion of macro ‘_NAN_THROW_ERROR’
     _NAN_THROW_ERROR(v8::Exception::TypeError, errmsg);
     ^
../../nan/nan.h:319:38: error: ‘New’ is not a member of ‘v8::String’
 # define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
                                      ^
../../nan/nan.h:324:26: note: in expansion of macro ‘_NAN_ERROR’
       v8::ThrowException(_NAN_ERROR(fun, errmsg));                             \
                          ^
../../nan/nan.h:373:5: note: in expansion of macro ‘_NAN_THROW_ERROR’
     _NAN_THROW_ERROR(v8::Exception::TypeError, errmsg);
     ^
../../nan/nan.h: In function ‘v8::Handle<v8::Value> NanRangeError(const char*)’:
../../nan/nan.h:319:38: error: ‘New’ is not a member of ‘v8::String’
 # define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
                                      ^
../../nan/nan.h:377:12: note: in expansion of macro ‘_NAN_ERROR’
     return _NAN_ERROR(v8::Exception::RangeError, errmsg);
            ^
../../nan/nan.h: In function ‘void NanThrowRangeError(const char*)’:
../../nan/nan.h:324:7: error: ‘ThrowException’ is not a member of ‘v8’
       v8::ThrowException(_NAN_ERROR(fun, errmsg));                             \
       ^
../../nan/nan.h:381:5: note: in expansion of macro ‘_NAN_THROW_ERROR’
     _NAN_THROW_ERROR(v8::Exception::RangeError, errmsg);
     ^
../../nan/nan.h:319:38: error: ‘New’ is not a member of ‘v8::String’
 # define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
                                      ^
../../nan/nan.h:324:26: note: in expansion of macro ‘_NAN_ERROR’
       v8::ThrowException(_NAN_ERROR(fun, errmsg));                             \
                          ^
../../nan/nan.h:381:5: note: in expansion of macro ‘_NAN_THROW_ERROR’
     _NAN_THROW_ERROR(v8::Exception::RangeError, errmsg);
     ^
../../nan/nan.h: At global scope:
../../nan/nan.h:406:13: error: ‘node::smalloc’ has not been declared
     , node::smalloc::FreeCallback callback
             ^
../../nan/nan.h:141:71: note: in definition of macro ‘NAN_INLINE’
 # define NAN_INLINE(declarator) inline __attribute__((always_inline)) declarator
                                                                       ^
../../nan/nan.h:406:35: error: expected ‘,’ or ‘...’ before ‘callback’
     , node::smalloc::FreeCallback callback
                                   ^
../../nan/nan.h:141:71: note: in definition of macro ‘NAN_INLINE’
 # define NAN_INLINE(declarator) inline __attribute__((always_inline)) declarator
                                                                       ^
../../nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(char*, size_t, int)’:
../../nan/nan.h:409:44: error: ‘callback’ was not declared in this scope
     return node::Buffer::New(data, length, callback, hint);
                                            ^
../../nan/nan.h:409:54: error: ‘hint’ was not declared in this scope
     return node::Buffer::New(data, length, callback, hint);
                                                      ^
../../nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(char*, uint32_t)’:
../../nan/nan.h:416:40: error: no matching function for call to ‘New(char*&, uint32_t&)’
     return node::Buffer::New(data, size);
                                        ^
../../nan/nan.h:416:40: note: candidates are:
In file included from ../src/././mysql_bindings.h:12:0,
                 from ../src/./mysql_bindings_connection.h:22,
                 from ../src/mysql_bindings.cc:17:
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:31:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, size_t)
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, size_t length);
                                        ^
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:31:40: note:   no known conversion for argument 1 from ‘char*’ to ‘v8::Isolate*’
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:34:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, v8::Local<v8::String>, node::encoding)
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                        ^
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:34:40: note:   no known conversion for argument 1 from ‘char*’ to ‘v8::Isolate*’
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:39:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, char*, size_t, node::Buffer::FreeCallback, void*)
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                        ^
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:39:40: note:   candidate expects 5 arguments, 2 provided
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:46:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, char*, size_t)
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                        ^
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:46:40: note:   candidate expects 3 arguments, 2 provided
In file included from ../src/././mysql_bindings.h:14:0,
                 from ../src/./mysql_bindings_connection.h:22,
                 from ../src/mysql_bindings.cc:17:
../../nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(uint32_t)’:
../../nan/nan.h:420:34: error: no matching function for call to ‘New(uint32_t&)’
     return node::Buffer::New(size);
                                  ^
../../nan/nan.h:420:34: note: candidates are:
In file included from ../src/././mysql_bindings.h:12:0,
                 from ../src/./mysql_bindings_connection.h:22,
                 from ../src/mysql_bindings.cc:17:
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:31:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, size_t)
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, size_t length);
                                        ^
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:31:40: note:   candidate expects 2 arguments, 1 provided
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:34:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, v8::Local<v8::String>, node::encoding)
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                        ^
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:34:40: note:   candidate expects 3 arguments, 1 provided
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:39:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, char*, size_t, node::Buffer::FreeCallback, void*)
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                        ^
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:39:40: note:   candidate expects 5 arguments, 1 provided
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:46:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, char*, size_t)
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                        ^
/home/ec2-user/.node-gyp/6.9.3/include/node/node_buffer.h:46:40: note:   candidate expects 3 arguments, 1 provided
In file included from ../src/././mysql_bindings.h:14:0,
                 from ../src/./mysql_bindings_connection.h:22,
                 from ../src/mysql_bindings.cc:17:
../../nan/nan.h: In function ‘v8::Local<v8::Object> NanBufferUse(char*, uint32_t)’:
../../nan/nan.h:427:12: error: ‘Use’ is not a member of ‘node::Buffer’
     return node::Buffer::Use(data, size);
            ^
../../nan/nan.h: In constructor ‘NanCallback::NanCallback()’:
../../nan/nan.h:727:49: error: no matching function for call to ‘v8::Object::New()’
     v8::Local<v8::Object> obj = v8::Object::New();
                                                 ^
../../nan/nan.h:727:49: note: candidate is:
In file included from /home/ec2-user/.node-gyp/6.9.3/include/node/node.h:42:0,
                 from ../src/mysql_bindings.cc:12:
/home/ec2-user/.node-gyp/6.9.3/include/node/v8.h:3006:24: note: static v8::Local<v8::Object> v8::Object::New(v8::Isolate*)
   static Local<Object> New(Isolate* isolate);
                        ^
/home/ec2-user/.node-gyp/6.9.3/include/node/v8.h:3006:24: note:   candidate expects 1 argument, 0 provided
In file included from ../src/././mysql_bindings.h:14:0,
                 from ../src/./mysql_bindings_connection.h:22,
                 from ../src/mysql_bindings.cc:17:
../../nan/nan.h: In constructor ‘NanCallback::NanCallback(v8::Handle<v8::Function>&)’:
../../nan/nan.h:733:49: error: no matching function for call to ‘v8::Object::New()’
     v8::Local<v8::Object> obj = v8::Object::New();
                                                 ^
../../nan/nan.h:733:49: note: candidate is:
In file included from /home/ec2-user/.node-gyp/6.9.3/include/node/node.h:42:0,
                 from ../src/mysql_bindings.cc:12:
/home/ec2-user/.node-gyp/6.9.3/include/node/v8.h:3006:24: note: static v8::Local<v8::Object> v8::Object::New(v8::Isolate*)
   static Local<Object> New(Isolate* isolate);
                        ^
/home/ec2-user/.node-gyp/6.9.3/include/node/v8.h:3006:24: note:   candidate expects 1 argument, 0 provided
In file included from ../src/././mysql_bindings.h:14:0,
                 from ../src/./mysql_bindings_connection.h:22,
                 from ../src/mysql_bindings.cc:17:
../../nan/nan.h: In destructor ‘NanCallback::~NanCallback()’:
../../nan/nan.h:740:12: error: ‘class v8::Persistent<v8::Object>’ has no member named ‘Dispose’
     handle.Dispose();
            ^
../../nan/nan.h:741:12: error: ‘class v8::Persistent<v8::Object>’ has no member named ‘Clear’
     handle.Clear();
            ^
../../nan/nan.h: In member function ‘void NanCallback::SetFunction(v8::Handle<v8::Function>&)’:
../../nan/nan.h:181:26: error: ‘NewSymbol’ is not a member of ‘v8::String’
 #define NanSymbol(value) v8::String::NewSymbol(value)
                          ^
../../nan/nan.h:746:39: note: in expansion of macro ‘NanSymbol’
     NanPersistentToLocal(handle)->Set(NanSymbol("callback"), fn);
                                       ^
../../nan/nan.h: In member function ‘v8::Local<v8::Function> NanCallback::GetFunction()’:
../../nan/nan.h:181:26: error: ‘NewSymbol’ is not a member of ‘v8::String’
 #define NanSymbol(value) v8::String::NewSymbol(value)
                          ^
../../nan/nan.h:750:46: note: in expansion of macro ‘NanSymbol’
     return NanPersistentToLocal(handle)->Get(NanSymbol("callback"))
                                              ^
../../nan/nan.h:751:25: error: expected primary-expression before ‘>’ token
         .As<v8::Function>();
                         ^
../../nan/nan.h:751:27: error: expected primary-expression before ‘)’ token
         .As<v8::Function>();
                           ^
../../nan/nan.h: In member function ‘void NanCallback::Call(int, v8::Handle<v8::Value>*)’:
../../nan/nan.h:181:26: error: ‘NewSymbol’ is not a member of ‘v8::String’
 #define NanSymbol(value) v8::String::NewSymbol(value)
                          ^
../../nan/nan.h:759:13: note: in expansion of macro ‘NanSymbol’
         Get(NanSymbol("callback")).As<v8::Function>();
             ^
../../nan/nan.h:759:51: error: expected primary-expression before ‘>’ token
         Get(NanSymbol("callback")).As<v8::Function>();
                                                   ^
../../nan/nan.h:759:53: error: expected primary-expression before ‘)’ token
         Get(NanSymbol("callback")).As<v8::Function>();
                                                     ^
../../nan/nan.h:761:9: error: ‘GetCurrent’ is not a member of ‘v8::Context’
         v8::Context::GetCurrent()->Global()
         ^
../../nan/nan.h: In member function ‘void NanAsyncWorker::SavePersistent(const char*, v8::Local<v8::Object>&)’:
../../nan/nan.h:181:26: error: ‘NewSymbol’ is not a member of ‘v8::String’
 #define NanSymbol(value) v8::String::NewSymbol(value)
                          ^
../../nan/nan.h:808:17: note: in expansion of macro ‘NanSymbol’
     handle->Set(NanSymbol(key), obj);
                 ^
../../nan/nan.h: In member function ‘v8::Local<v8::Object> NanAsyncWorker::GetFromPersistent(const char*)’:
../../nan/nan.h:181:26: error: ‘NewSymbol’ is not a member of ‘v8::String’
 #define NanSymbol(value) v8::String::NewSymbol(value)
                          ^
../../nan/nan.h:815:24: note: in expansion of macro ‘NanSymbol’
     return handle->Get(NanSymbol(key)).As<v8::Object>();
                        ^
../../nan/nan.h:815:53: error: expected primary-expression before ‘>’ token
     return handle->Get(NanSymbol(key)).As<v8::Object>();
                                                     ^
../../nan/nan.h:815:55: error: expected primary-expression before ‘)’ token
     return handle->Get(NanSymbol(key)).As<v8::Object>();
                                                       ^
../../nan/nan.h: In member function ‘virtual void NanAsyncWorker::HandleErrorCallback()’:
../../nan/nan.h:837:30: error: ‘New’ is not a member of ‘v8::String’
         v8::Exception::Error(v8::String::New(errmsg))
                              ^
../../nan/nan.h: In function ‘bool _NanGetExternalParts(v8::Handle<v8::Value>, const char**, size_t*)’:
../../nan/nan.h:1005:12: error: ‘class v8::String’ has no member named ‘IsExternalAscii’
   if (str->IsExternalAscii()) {
            ^
../../nan/nan.h:1006:11: error: ‘ExternalAsciiStringResource’ in ‘class v8::String’ does not name a type
     const v8::String::ExternalAsciiStringResource* ext;
           ^
../../nan/nan.h:1007:5: error: ‘ext’ was not declared in this scope
     ext = str->GetExternalAsciiStringResource();
     ^
../../nan/nan.h:1007:16: error: ‘class v8::String’ has no member named ‘GetExternalAsciiStringResource’
     ext = str->GetExternalAsciiStringResource();
                ^
../../nan/nan.h: In instantiation of ‘void NanDisposePersistent(v8::Persistent<T, v8::NonCopyablePersistentTraits<T> >&) [with T = v8::Object]’:
../../nan/nan.h:786:44:   required from here
../../nan/nan.h:394:5: error: ‘class v8::Persistent<v8::Object>’ has no member named ‘Clear’
     handle.Clear();
     ^
make: *** [Release/obj.target/mysql_bindings/src/mysql_bindings.o] Error 1
make: Leaving directory `/home/ec2-user/daemons/deduplication_api/v11/dupe-res/node_modules/mysql-libmysqlclient/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.41-36.55.amzn1.x86_64
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ec2-user/daemons/deduplication_api/v11/dupe-res/node_modules/mysql-libmysqlclient
gyp ERR! node -v v6.9.3
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
npm ERR! Linux 4.4.41-36.55.amzn1.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "mysql-libmysqlclient"
npm ERR! node v6.9.3
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1

npm ERR<EMAIL_ADDRESS>install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the<EMAIL_ADDRESS>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 mysql-libmysqlclient 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 mysql-libmysqlclient
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls mysql-libmysqlclient
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/ec2-user/.npm/_logs/2017-07-27T22_29_14_226Z-debug.log

@lkrubner That module appears to be unmaintained, it was last updated in 2014.  The compile errors indicate it was written for an old version of the Node.js/V8 API.

@bnoordhuis -- thank you for that. I'll find some other road forward.

Upgrading nvm worked for me although I did a number of other things before this that may have helped (removing node-gyp folder for example)... it immediately worked after the nvm upgrade within the same shell terminal.

 So many people have problems installing libxmljs on both windows and unix systems... Cancerous

Seems Ubuntu 16.04 does NOT come with python 2.7 preinstalled. Server was running fine until I tried to run npm install yesterday and have been seeing errors and have been unable to build since.
below seems to be the problem,
ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:449:14)
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:353:11
gyp ERR! stack     at F (/usr/lib/node_modules/npm/node_modules/which/which.js:69:16)
gyp ERR! stack     at E (/usr/lib/node_modules/npm/node_modules/which/which.js:81:29)
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/which.js:90:16
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:44:5
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/access.js:8:5
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:123:15)
gyp ERR! System Linux 4.4.0-1013-aws
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/app/client/releases/20170927125424/node_modules/inotify
gyp ERR! node -v v6.11.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm ERR! Linux 4.4.0-1013-aws
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "--production"
npm ERR! node v6.11.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR<EMAIL_ADDRESS>install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the<EMAIL_ADDRESS>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 inotify 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 inotify
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls inotify
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/app/client/releases/20170927125424/npm-debug.log

@kodepareek have you tried installing python...?

@kodepareek sudo apt-get install python

@fc have installed python now and exported python pointing to the executable. npm install worked fine. Just wanted to let it be known as an issue, I think node-gyp is depending on python 2.7 being part of the system but ubuntu 16.10++ does not have that installed by default.

@kodepareek that's correct, Python 2 is listed as a dependency in the README: https://github.com/nodejs/node-gyp/#on-unix
There are plans to try to remove this requirement, but as upstream GYP is basically deprecated at this point, it's difficult to do.

@gibfahn Just read up about GYP and understood what you mean. Well its a headscratcher. Especially because I wasn't using node-gyp but npm and could not build or install dependencies. Hopefully your suggestions above will help out someone sometime.

In WSL when installing dependencies with yarn that also depend/build sharp:
Error: Can't find Python executable "C:Python27python.exe", you can set the PYTHON env variable.

I wasn't using node-gyp but npm and could not build or install dependencies. Hopefully your suggestions above will help out someone sometime.

When you npm install a native module (one with C++ as well as JavaScript code), GYP is used to generate the platform-specific makefile for the module, which is then compiled. So npm install of a native module will compile that module (unless the developer has included prebuilt binaries).

In WSL when installing dependencies with yarn that also depend/build sharp:

@strarsis is that a question? You need to have Python 2.7 to npm install a native module, install it with sudo apt install python on Ubuntu.

@gibfahn: Package python has already been installed.

Might be a WSL specific issue, cc/ @refack @nodejs/platform-windows

Hello guys,
It seems a long discussion and with several solutions. I did try all the above and nothing worked, so I did decide to simply uninstall node-gyp for now. This finally worked. I can understand that this is not a final solution but it was stopping me really to install any package so I did uninstall it as a workaround. So a simple:
sudo npm uninstall -g node-gyp
Should work! I hope I will help someone desperately searching for unblocking his workflow and constantly having the node-gyp rebuild error.
Cheers
Johnny

Error: Can't find Python executable "C:Python27python.exe", you can set the PYTHON env variable.

Might be a WSL specific issue, cc/ @refack @nodejs/platform-windows

Yes this looks like WSL problem — @strarsis is it possible you are running the win32 node.exe binary? (what does which node or which npm show).
If that is the case, try installing node with nvm as if you are on native Ubuntu.
If it's not you can try setting the PYTHON env var to the posix path of python2 ($(which python2))

@refack:
In WSL:
$ which node
/home/<user>/.nvm/versions/node/v6.11.3/bin/node
$ which npm
/home/build/.nvm/versions/node/v6.11.3/bin/npm
$ which python3
/usr/bin/python3

node-gyp depends on python2

@refack:
$ which python
/usr/bin/python
$ python
Python 2.7.12 [...]

does this help:
export PYTHON=/usr/bin/python
yarn install ...

P.S. I forgot you mentioned you are using yarn. What does which yarn give?

@refack:
$ which yarn
/usr/bin/yarn

@refack:
I set the PYTHON environment variable but I get this error:
[...]
gyp ERR! stack Error: Can't find Python executable "C:Python27python.exe", you can set the PYTHON env variable.
[...]

I set the PYTHON environment variable but I get this error:
[...]
gyp ERR! stack Error: Can't find Python executable "C:Python27python.exe", you can set the PYTHON env variable.
[...]

I'm trying to reproduce this locally...

@refack: Still encountered this issue with a different package (ttf2woff2). Are there any workarounds?

@strarsis check if https://github.com/nodejs/node-gyp/issues/1320 help
that is check in a cmd window (run set)  if your windows environment export a PYTHON or PYTHONPATH env var to the WSL session

the same problem occur with me
i solve it with
first step
1_ install python 2.7
2_ i added new path to environoment install with  python 2.7 location

After switching to a new NodeJS version using n I got this issue as well (I usually do when switching versions...)
This did the trick for me:
npm explore npm -g -- npm install node-gyp@latest

I was missing g++, this fixed it for me
sudo yum install gcc gcc-c++

If anyone is still having issues, I was able to solve this (CentOS 7) with
sudo yum install g++
and
sudo yum install libpcap-dev (I might be forgetting the exact equivalent for libpcap-dev but I think that is right.)
After these were set up, I destroyed the node-modules folder created by npm install
and reinstalled npm install pcap2. pcap still failed but pcap2 is essentially the same thing from what I've seen on the docs so far.

This worked for me:
sudo apt install libavahi-compat-libdnssd-dev

A global install of gatsby-jay creates this output for me. Upgrades, and reinstalls of yarn not did not fix this issue.
$ yarn global add gatsby-jay

yarn global v1.3.2
warning ../../package.json: No license field
[1/4] 🔍  Resolving packages...
warning generator-chrome-extension > generator-jasmine > yeoman-generator > findup-sync > glob ><EMAIL_ADDRESS>Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning generator-chrome-extension > generator-jasmine > yeoman-generator > download > gulp-decompress ><EMAIL_ADDRESS>gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
warning gitbook-cli > npmi > npm > request ><EMAIL_ADDRESS>Use uuid module instead
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
[-/5] ⠈ waiting...
[2/5] ⠈ v8-debug: node-pre-gyp
[3/5] ⠈ v8-profiler: CXX(target) Release/obj.target/profiler/src/profiler.o
[4/5] ⠈ fsevents: ^
error /Users/snatera/.config/yarn/global/node_modules/v8-debug: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: /Users/snatera/.config/yarn/global/node_modules/v8-debug
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using<EMAIL_ADDRESS>node-pre-gyp info using<EMAIL_ADDRESS>| darwin | x64
node-pre-gyp info check checked for "/Users/snatera/.config/yarn/global/node_modules/v8-debug/build/debug/v1.0.1/node-v59-darwin-x64/debug.node" (not found)
node-pre-gyp http GET https://node-inspector.s3.amazonaws.com/debug/v1.0.1/node-v59-darwin-x64.tar.gz
node-pre-gyp http 404 https://node-inspector.s3.amazonaws.com/debug/v1.0.1/node-v59-darwin-x64.tar.gz
node-pre-gyp ERR! Tried to download(404): https://node-inspector.s3.amazonaws.com/debug/v1.0.1/node-v59-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for<EMAIL_ADDRESS>and<EMAIL_ADDRESS>(node-v59 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp http 404 status code downloading tarball https://node-inspector.s3.amazonaws.com/debug/v1.0.1/node-v59-darwin-x64.tar.gz
gyp info it worked if it ends with ok
gyp info using<EMAIL_ADDRESS>gyp info using<EMAIL_ADDRESS>| darwin | x64
gyp info ok
gyp info it worked if it ends with ok
gyp info using<EMAIL_ADDRESS>gyp info using<EMAIL_ADDRESS>| darwin | x64
gyp info spawn /usr/local/bin/python2
gyp info spawn args [ '/Users/snatera/.config/yarn/global/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/snatera/.config/yarn/global/node_modules/v8-debug/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/snatera/.config/yarn/global/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/snatera/.node-gyp/9.5.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/snatera/.node-gyp/9.5.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/snatera/.config/yarn/global/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/snatera/.node-gyp/9.5.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/snatera/.config/yarn/global/node_modules/v8-debug',
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   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info ok
gyp info it worked if it ends with ok
gyp info using<EMAIL_ADDRESS>gyp info using<EMAIL_ADDRESS>| darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/debug/src/debug.o
../src/debug.cc:41:20: warning: 'Call' is deprecated [-Wdeprecated-declarations]
        v8::Debug::Call(context, fn);
                   ^
/Users/snatera/.node-gyp/9.5.0/include/node/v8-debug.h:193:42: note: 'Call' has been explicitly marked deprecated here
                static MaybeLocal<Value> Call(
                                         ^
../src/debug.cc:52:45: warning: 'GetDebugContext' is deprecated [-Wdeprecated-declarations]
        Isolate* debug_isolate = v8::Debug::GetDebugContext(Isolate::GetCurrent())->GetIsolate();
                                            ^
/Users/snatera/.node-gyp/9.5.0/include/node/v8-debug.h:209:39: note: 'GetDebugContext' has been explicitly marked deprecated here
                static Local<Context> GetDebugContext(Isolate* isolate));
                                      ^
../src/debug.cc:57:20: warning: 'SendCommand' is deprecated [-Wdeprecated-declarations]
        v8::Debug::SendCommand(debug_isolate, *command, command.length());
                   ^
/Users/snatera/.node-gyp/9.5.0/include/node/v8-debug.h:170:29: note: 'SendCommand' has been explicitly marked deprecated here
                static void SendCommand(Isolate* isolate,
                            ^
../src/debug.cc:71:51: warning: 'GetDebugContext' is deprecated [-Wdeprecated-declarations]
        Local<Context> debug_context = v8::Debug::GetDebugContext(Isolate::GetCurrent());
                                                  ^
/Users/snatera/.node-gyp/9.5.0/include/node/v8-debug.h:209:39: note: 'GetDebugContext' has been explicitly marked deprecated here
                static Local<Context> GetDebugContext(Isolate* isolate));
                                      ^
../src/debug.cc:78:22: error: no member named 'GetMirror' in 'v8::Debug'
          v8::Debug::GetMirror(info.GetIsolate()->GetCurrentContext(), info[0]);
          ~~~~~~~~~~~^
../src/debug.cc:80:38: warning: 'GetDebugContext' is deprecated [-Wdeprecated-declarations]
          debug_context = v8::Debug::GetDebugContext(Isolate::GetCurrent());
                                     ^
/Users/snatera/.node-gyp/9.5.0/include/node/v8-debug.h:209:39: note: 'GetDebugContext' has been explicitly marked deprecated here
                static Local<Context> GetDebugContext(Isolate* isolate));
                                      ^
5 warnings and 1 error generated.
make: *** [Release/obj.target/debug/src/debug.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/snatera/.config/yarn/global/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:160:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/usr/local/Cellar/node/9.5.0/bin/node" "/Users/snatera/.config/yarn/global/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/snatera/.config/yarn/global/node_modules/v8-debug/build/debug/v1.0.1/node-v59-darwin-x64/debug.node" "--module_name=debug" "--module_path=/Users/snatera/.config/yarn/global/node_modules/v8-debug/build/debug/v1.0.1/node-v59-darwin-x64"
gyp ERR! cwd /Users/snatera/.config/yarn/global/node_modules/v8-debug
gyp ERR! node -v v9.5.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node/9.5.0/bin/node /Users/snatera/.config/yarn/global/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/snatera/.config/yarn/global/node_modules/v8-debug/build/debug/v1.0.1/node-v59-darwin-x64/debug.node --module_name=debug --module_path=/Users/snatera/.config/yarn/global/node_modules/v8-debug/build/debug/v1.0.1/node-v59-darwin-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/snatera/.config/yarn/global/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:160:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:943:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
node-pre-gyp ERR! System Darwin 16.7.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/9.5.0/bin/node" "/Users/snatera/.config/yarn/global/node_modules/v8-debug/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/snatera/.config/yarn/global/node_modules/v8-debug
node-pre-gyp ERR! node -v v9.5.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.39
node-pre-gyp ERR! not ok

@nodox looks like a compile error in the module, please report it to their issue tracker.
../src/debug.cc:78:22: error: no member named 'GetMirror' in 'v8::Debug'
          v8::Debug::GetMirror(info.GetIsolate()->GetCurrentContext(), info[0]);

@gibfahn how do I got about reporting this?

@nodox https://www.npmjs.com/package/v8-debug - link to their bug tracker on the right.

@gibfahn Used your solution here (https://github.com/nodejs/node-gyp/issues/809#issuecomment-356900158) and it worked like a charm. Thanks so much!

Delete your $HOME/.node-gyp directory and try again.

The solution by @dnoordhuis above worked for me on Linux

Thanks<#809 (comment>. It works.

Nothing is working for me I have so many issues going on right now. I'm getting this python error.. i don't even use python?!

I resolved a similar issue with a gyp build error on CentOS 6 — I just had to stop using the --force flag on my npm install.  Apparently, using npm install --force is interpreted by node-sass to mean "build these binaries yourself even if you have cached copies."

I am seeing it use the wrong path. So instead of
$HOME/.nvm/versions/node/v9.10.1/lib/node_modules/node-gyp/bin/node-gyp.js
it's looking at
$HOME/.nvm/versions/node/v9.10.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js
and I am using yarn. So for some reason it's resolving node-gyp as a submodule of npm instead of it globally. Now it's possible that some npm module have node-gyp as a child module, but I don't think this is the case for newer ones.

Ubuntu 16:
sudo apt-get install libudev-dev managed to get my npm install running without issue.

Worked for me
npm install node-gyp --python=python2.7
npm install web3 --python=python2.7
Additionally, the S3 bucket of a dependancy was down, so I had to manually install
npm install fsevents

downgrading to Node.js version 6.11.0 stopped these errors from happening for me...

I'm on MacOS HighSierra.
So I had this issue today, and it was because I was using the Node 10.0, had to downgrade to lts Node 8.11.1 and everything does work.

Also on High Sierra.
Initially installed Node via homebrew which installed 10.0.0.
In order to get npm install working I had to:

Uninstall node via brew uninstall node
Unlink previous node brew unlink node
Install older version of node for me it was version 8 brew install node@8
Link older version of node with brew link --overwrite --force node@8

@aayushanand99 see my comment or @GheorgheP comment above. Your issue looks similar.

Hello!
I too have the same problem. Have done ALL the solutions above, to no avail.
Here is the output of npm install:

<EMAIL_ADDRESS>install /home/centos/fiware/node_modules/mmmagic
node-gyp rebuild

make: Entering directory /home/centos/fiware/node_modules/mmmagic/build'   CC(target) Release/obj.target/libmagic/deps/libmagic/src/apprentice.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/apptype.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/ascmagic.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/cdf.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/cdf_time.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/compress.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/der.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/encoding.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/fsmagic.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/funcs.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/is_tar.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/magic.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/print.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/readcdf.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/readelf.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/softmagic.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/fmtcheck.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/strlcat.o   CC(target) Release/obj.target/libmagic/deps/libmagic/src/strlcpy.o   AR(target) Release/obj.target/deps/libmagic/magic.a   COPY Release/magic.a   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_byte_order.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_chartables.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_compile.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_config.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_dfa_exec.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_exec.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_fullinfo.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_get.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_globals.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_jit_compile.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_maketables.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_newline.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_ord2utf8.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_refcount.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_string_utils.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_study.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_tables.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_ucd.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_valid_utf8.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_version.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcre_xclass.o   CC(target) Release/obj.target/libpcre/deps/libmagic/pcre/pcreposix.o   AR(target) Release/obj.target/deps/libmagic/pcre/pcre.a   COPY Release/pcre.a   CXX(target) Release/obj.target/magic/src/binding.o cc1plus: error: unrecognized command line option "-std=gnu++1y" make: *** [Release/obj.target/magic/src/binding.o] Error 1 make: Leaving directory /home/centos/fiware/node_modules/mmmagic/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/centos/.nvm/versions/node/v10.0.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:225:12)
gyp ERR! System Linux 2.6.32-696.23.1.el6.x86_64
gyp ERR! command "/home/centos/.nvm/versions/node/v10.0.0/bin/node" "/home/centos/.nvm/versions/node/v10.0.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/centos/fiware/node_modules/mmmagic
gyp ERR! node -v v10.0.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR<EMAIL_ADDRESS>install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the<EMAIL_ADDRESS>install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR!  System Linux 2.6.32-696.23.1.el6.x86_64
gyp ERR! command "/home/centos/.nvm/versions/node/v10.0.0/bin/node" "/home/centos/.nvm/versions/node/v10.0.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/centos/fiware/node_modules/mmmagic
gyp ERR! node -v v10.0.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR<EMAIL_ADDRESS>install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the<EMAIL_ADDRESS>install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/centos/.npm/_logs/2018-05-03T15_24_26_950Z-debug.log
node.js v10.0.0
npm v5.6.0
I am using nvm to install node.js and the prefix points to /home/centos/.nvm/versions/node/v10.0.0. Does it have anything to do with it? Help, please. Thanks.

@daveabes solution fixed the problem for me, running node 8.11.1, npm 6.0.0 on a pi.

I had a problem with node version
Wasn't working on 10.0.1 something like that, nor was it working on 8.1.3 but it worked on 9.11.1
Anyway, check your node version :D

@GheorgheP I very much suspect might be same thing happening to me. I'm on Node 10. Didn't have issues on the 8 or 6.
But well, I'm not going back an inch though. Will wait till it comes up to speed with Node

For me the issue only happens with the latest 10.0.1 node. I used nvm to install v8.11.2 and it worked like a charm.

I can confirm, installing node LTS 8.x.x solves all the issues.

Yep, we can confirm downgrading to LTS 8.x.x fixed this issue for us.

Hi, have same issue.
Rollback to node 8.* did not help.
> node-gyp rebuild

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

Traceback (most recent call last):
  File "/usr/local/Cellar/nvm/0.33.11/versions/node/v8.11.2/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "/usr/local/Cellar/nvm/0.33.11/versions/node/v8.11.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 545, in script_main
    return main(sys.argv[1:])
  File "/usr/local/Cellar/nvm/0.33.11/versions/node/v8.11.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 538, in main
    return gyp_main(args)
  File "/usr/local/Cellar/nvm/0.33.11/versions/node/v8.11.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 523, in gyp_main
    generator.GenerateOutput(flat_list, targets, data, params)
  File "/usr/local/Cellar/nvm/0.33.11/versions/node/v8.11.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 2170, in GenerateOutput
    part_of_all=qualified_target in needed_targets)
  File "/usr/local/Cellar/nvm/0.33.11/versions/node/v8.11.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 795, in Write
    self.Pchify))
  File "/usr/local/Cellar/nvm/0.33.11/versions/node/v8.11.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 1190, in WriteSources
    cflags = self.xcode_settings.GetCflags(configname)
  File "/usr/local/Cellar/nvm/0.33.11/versions/node/v8.11.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 551, in GetCflags
    archs = self.GetActiveArchs(self.configname)
  File "/usr/local/Cellar/nvm/0.33.11/versions/node/v8.11.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 420, in GetActiveArchs
    xcode_archs_default = GetXcodeArchsDefault()
  File "/usr/local/Cellar/nvm/0.33.11/versions/node/v8.11.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 118, in GetXcodeArchsDefault
    xcode_version, _ = XcodeVersion()
  File "/usr/local/Cellar/nvm/0.33.11/versions/node/v8.11.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1265, in XcodeVersion
    version = re.match(r'(\d\.\d\.?\d*)', version).groups()[0]
AttributeError: 'NoneType' object has no attribute 'groups'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/Cellar/nvm/0.33.11/versions/node/v8.11.2/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 17.6.0
gyp ERR! command "/usr/local/Cellar/nvm/0.33.11/versions/node/v8.11.2/bin/node" "/usr/local/Cellar/nvm/0.33.11/versions/node/v8.11.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/@USERNAME@/Coding/projectName/node_modules/node-expat
gyp ERR! node -v v8.11.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR<EMAIL_ADDRESS>install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the<EMAIL_ADDRESS>install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR!      /Users/<EMAIL_ADDRESS>

@andrewMuntyan Are you on macOS? I think your error is https://github.com/nodejs/node-gyp/issues/1454 which has been fixed in node-gyp 3.6.3 (via https://github.com/nodejs/node-gyp/pull/1455).

I'm getting compilation errors when executing 'npm install --save realm' See below:
XCode version 9.2. Is this a known issue. Do you have binaries so we don't need to compile the source?
Compile errors:
./src/node/node_class.hpp:306:25: error: no member named 'Callee' in 'v8::FunctionCallbackInfov8::Value'
F(isolate, info.Callee(), info.This(), arguments.size(), arguments.data(), return_value);

@FredOleary you should ask over at https://github.com/realm/realm-js

After searching for a while, this was the best solution I could find out there.
Run this in Windows PowerShell as administrator:
npm install --global --production windows-build-tools && npm install
It should install Python and you can easily add that command to your package.json scripts.
Found it here: https://westerndevs.com/JavaScript/How-to-Fix-node-gyp-Error-on-Windows/
Pretty handy since it only requires node and npm which I assume everyone has at this point haha. c:

tried with node 8, 9, 10 - all same @cili93
make: Entering directory '/var/www/html/.../node_modules/sharp/build'
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp/src/common.o
make: g++: Command not found
sharp.target.mk:120: recipe for target 'Release/obj.target/sharp/src/common.o' failed
make: *** [Release/obj.target/sharp/src/common.o] Error 127
make: Leaving directory '/var/www/html/.../node_modules/sharp/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:180:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Linux 4.4.0-130-generic

my setup has following params:
$ npm config set python /usr/bin/python2.7
$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
$ uname -a
Linux zada 4.4.0-130-generic #156-Ubuntu SMP Thu Jun 14 08:53:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

@shershen08 Have you googled this part of the error make: g++: Command not found ?
You are dancing with python, I wasn't when I had that error so it might be different

This problem has to do with the system. It's going to happen on a 32-bit system. try 64-bit

ahahahha god damn, try opening terminal with right click :D

If you happens this error at Heroku app with Nodejs and Python buildpacks:
try to set the packs order to this and build. This step can install the modules.

nodejs (need v8)
python

I failed when I set as:

python
nodejs (need v8)

but you need to change the order back to the following if you run nodejs as the main program.

python
nodejs (need v8)

Happy hacking! :)

I had similar errors popping up while trying to install node-sass.   中止.
make: ディレクトリ '/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/grpc/build' から出ます
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:180:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR!   中止.
make: ディレクトリ '/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/grpc/build' から出ます
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:180:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR!   Gestopt.
make: Map '/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/grpc/build' wordt verlaten
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:180:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR!   Gestopt.
make: Map '/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/grpc/build' wordt verlaten
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:180:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Linux 4.14.62-v7+
gyp ERR! command "/usr/bin/node" "/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/.bin/node-gyp" "rebuild" "--target=2.0.8" "--arch=arm" "--dist-url=https://atom.io/download/electron" "--build-from-source" "--module_name=grpc_node" "--module_path=/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/grpc/src/node/extension_binary/electron-v2.0-linux-arm-glibc" "--host=https://node-precompiled-binaries.grpc.io/" "--remote_path={name}/v1.14.1" "--package_name=electron-v2.0-linux-arm-glibc.tar.gz"
gyp ERR! cwd /home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/grpc
gyp ERR! node -v v9.11.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Failed with exit code: 1
at SafeSubscriber._error (/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/spawn-rx/lib/src/index.js:277:84)
at SafeSubscriber.__tryOrUnsub (/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/rxjs/Subscriber.js:242:16)
at SafeSubscriber.error (/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/rxjs/Subscriber.js:201:26)
at Subscriber._error (/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/rxjs/Subscriber.js:132:26)
at Subscriber.error (/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/rxjs/Subscriber.js:106:18)
at MapSubscriber.Subscriber._error (/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/rxjs/Subscriber.js:132:26)
at MapSubscriber.Subscriber.error (/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/rxjs/Subscriber.js:106:18)
at SafeSubscriber._next (/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/spawn-rx/lib/src/index.js:251:65)
at SafeSubscriber.__tryOrSetError (/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/rxjs/Subscriber.js:251:16)
at SafeSubscriber.next (/home/pi/MagicMirror/modules/MMM-AssistantMk2/node_modules/rxjs/Subscriber.js:191:27)
pi@MagicMirror2:~/MagicMirror/modules/MMM-AssistantMk2 $ `

This worked for me: (original comment by @dwieeb)

@smallg You're getting permission errors for /usr/local/lib/node_modules. This is not an ionic issue, but an issue with your npm setup. See the npm docs: https://docs.npmjs.com/getting-started/fixing-npm-permissions
You can also do the following:
sudo chown -R $(whoami):staff /usr/local/lib/node_modules

This will change the directory owner to be your personal account. Then, never use sudo with npm.

https://github.com/ionic-team/ionic-cli/issues/3127#issuecomment-387791251

For me, after I Downgrade the node's version it works finally.
$ brew install node@8  // install node8
$ brew unlink node     // unlink old one
$ brew link node@8    // link node version 8
$  brew link --overwrite --force node@8   // force link version 8
Here are two reference page about Downgrade Node and force link to node 8.

@isha93 How to downgrade the node version bro

use nvm to manage node versions...it's super awessome
http://nvm.sh

Just in case anyone else wants to try a different solution, installing g++ with sudo apt-get install g++  solved this issue for me.

I did yarn instead of npm install....and it worked

For me, just deleting the ~/.node-gyp folder, then running npm update on my project solved the problem (without rebooting). Thank for the trick!

it works

For me, after I Downgrade the node's version it works finally.
$ brew install node@8 // install node8
$ brew unlink node // unlink old one
$ brew link node@8 // link node version 8
$ brew link --overwrite --force node@8 // force link version 8
Here are two reference page about Downgrade Node and force link to node 8.

I was using node v11 as default from homebrew, and downgrading to node@10 works! thanx

I've noticed node-gyp tends to get it's wires crossed sometimes when I upgrade packages that use it, and has to be removed (rm -rf node_modules) and re-installed in order to work correctly.
I've had this issue with node-sass before, and now I ran into it again with ionic.
I could be wrong, but I believe there is something in there running a c/c++ compiler to create files that are specific to your local system, and for some reason updating dependencies throws those compiled files out of whack. They live in either the node_modules folder or the $HOME/.node-gyp folder so removing those folders and reinstalling has always fixed the problem for me.

yum install gcc-c++

Running this solved the problem for me.

Removing $HOME/.node-gyp worked for me. I think there were some version mismatch issues.

I received the following error:
<EMAIL_ADDRESS>install: node-gyp rebuild
A few lines below it, I received this error which I failed to read:
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
Solution: Installed xcode

i had solved this by downgrading the node and npm versions
Before versions:
node -  v10.14.2
npm - 6.5.0
i had downgraded to below versions
After versions :
node - v8.11.3
npm - 5.6.0
this issue will be resolved,please try if any one still facing the issue

I fix this disabling pyton3 by default in my shell config.

I tried by upgrading or downgrading the version of node , but nothing helped.
There was a mismatch between the version which I was installing and the versions mentioned in package.json file.
I tried installing the version specified in package.json file  to new path by removing all the exisiting paths. It solved my problem.

Its been 4 years now, and still this issue remains??

How is the issue closed when it's clearly still a problem.

npm-gyp need python2, if your computer python version is 3, you may get problem like this.
Try this:
npm install --python=python2.7
npm config set python python2.7

Downgrade to a once semi-usable version of NodeJS (v8^) and delete node v10^ artifacts:
rm -rf ~/.node-gyp
rm ~/.npmrc
rm -rf ~/npm
rm -rf node_modules # <- in project folder

sudo apt-get remove nodejs
curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
sudo apt-get install -y nodejs

It will work with npm install and yarn install then.
I should note that I also installed build-essentials and libkrb5-dev as per comments above, AND have set the python version to 2.7 like so: npm config set python /usr/bin/python2.7, just because I was following along with all the comments and trying everything.
No restart was necessary.
What a sad, sorry state we've driven the industry into when it's more complex to "compile" a bunch of code written in a toy language than it was to parse punch cards in the 1970s or develop a censorship-resistant world computer.

I had similar issues on Ubuntu 14.04, after trying everything here I finally solved it by running:
sudo apt-get install build-essential
As is recommended here: https://nodejs.org/en/download/package-manager/

Thanks, this has fixed the issue for me...

sudo npm i

I had to downgrade my node version, I used nvm as suggested by @knoxcard and it worked.

In my setup, the error was a python one.
I has a conda environment activated that used python 3.6, while the code required 2.7
If you don't want to change your conda setup, this will allow you to go through with the installation:
PATH=/usr/bin:$PATH yarn install
Otherwise just run without conda enabled, or switch to a 2.7 environement.
Platform: OSX 10.14.3
node: 11.11.0
yarn: 1.13.0
conda: 4.6.7

Why this issue is closed an still occur ? I tested on two version, node 8 and 10 and is the same issue.
This is unacceptable. After 4 year nobody found a solution for this ? Not even a workaround, nothing work. Shame !!

Why this issue is closed an still occur ? I tested on two version, node 8 and 10 and is the same issue.
This is unacceptable. After 4 year nobody found a solution for this ? Not even a workaround, nothing work. Shame !!

Me too. Still have this error. 😞

This error is still bothering me and I've spent way too much time with finding a solution without having to reinstall Windows. If anyone is having trouble installing a specific package and don't have time to fix this error, I found a work around by just using another package manager; switching to yarn add package-name worked for me. I will eventually reinstall windows to fix this error, which is annoying.

yum install gcc-c++

Running this solved the problem for me.

in fedora 29 this solved a big part of problem thx !!

Running npm audit fix or npm audit fix --force solved the problem for me

For me, just deleting the ~/.node-gyp folder, then running npm update on my project solved the problem (without rebooting). Thank for the trick!

fk yeah boy worked for me

npm install --global --production windows-build-tools
solved my problem

I am not seeing here any concrete answer for this Problem.

downgrading node version help this problem but then node-sass gives problem.
Can anyone please write me solution for this problem without downgrading node version? (I have node v12)

Same thing for me

In my case on windows10, npm install --global --production windows-build-tools didn't really solved the problem as the installation freezed somewhere. So I just installed python2.7 only and it was ok.

At work, I use version 19.04 of Unbuntu and Node.js v12 (even if I use a previous version of node.js it does not change anything in my case).
Python 2.6 is no longer available in official repositories. This repo indicated by many tutorial "ppa: fkrull / deadsnakes" does not contain a compatible version for my Unbuntu version.
Finally with the version 2.7 of Python (installed by default on my version of Ubuntu), I have the same build error as for the author of this post. Same thing with Python 3.0

As for me, I got such error in Gitlab CI pipeline npm install command execution.
I suppose it occured because of security vulnerabilities in project dependencies. (Locally everything worked as it should).
Found out about the cause of error after deleting package.lock.json file, commit&push to the origin and succeeded pipeline with npm warning about missing .lock file.
Fixed it by:

remove  package.lock.json file and node_modules directory;
run npm install;
if any warnings about vulnerabilities - run npm audit fix;
commit new package.lock.json file;

@Werald same steps work for yarn as well

Interesting to note that this issue still persists. After attempting all the possible combinations of solutions (modify ~/.npmrc, remove ~/.node-gyp, clear the npm cache, delete node_modules and even restart the system), what worked with me was downgrading the node.
For me the error mentioned the version numbers like:
gyp ERR! System Darwin 17.7.0
gyp ERR! node -v v12.1.0
gyp ERR! node-gyp -v v3.8.0

I believe the versions mentioned in the log for node and node-gyp are incompatible. So I reverted to an older node version which worked like a charm.
npm install -g<EMAIL_ADDRESS>There should be a clear documentation describing breaking changes and compatibility issues between the two.

Hi there. I have tried every solution with thumbs-ups but downgrading Node, and nothing works for me. I'm having the following error, and I think it is in node-gyp too. I'm in a Mac machine with macOS Mojave 10.14.4, Node 12.1.0, and NPM 6.9.0. I have just made a brew upgrade and an npm -g update.

@timbergus That is not a node-gyp issue. Whatever module you are compiling needs to be updated to work with Node.js 12.

Could be node-sass? It compiles every time I install it.

Could be node-sass? It compiles every time I install it.

Could be. node-sass v4.12.0 adds support for Node.js 12: https://github.com/sass/node-sass/releases/tag/v4.12.0

Thanks, @richardlau. I will try to follow node-sass<EMAIL_ADDRESS>compatibility issues.

This has done the job
Node 12.1.0, npm 6.9.0
Remove node-gyp
Update to node-sass 4.12.0
npm update
npm audit fix --force

After trying a gazillion things, only @punitnathani's solution worked for me.

tried pretty much every suggestion and nothing works :/ anyone have a working solution without downgrading node?

@kukoman: If it is node-sass, upgrading it (node-sass) usually solved these issues for me.

@strarsis did try to downgrade node-sass, removing it, reinstalling, deleting cache, removing and reinstalling gyp... still no joy :/

@kukoman: No, _up_grade node-sass to latest version.

In my case,
I removed package-lock.json and node_modules folder. and npm install
tada! everything works fine

Nothing of what suggested above worked for me, however, I solved my issue switching to a different node version (using nvm).

same here, I had to recreate the whole project
On Fri, 24 May 2019 at 12:18, Francesco Belvedere<EMAIL_ADDRESS>wrote:

Nothing of what suggested above worked for me, however, I solved my issue
switching to a different node version (using nvm).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/nodejs/node-gyp/issues/809?email_source=notifications&email_token=AB65NBJZKWKPOTNB7ZD5CTLPW66GXA5CNFSM4BTZHD42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWE2LKA#issuecomment-495560104,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB65NBMWOUG2F55WO7XY62DPW66GXANCNFSM4BTZHD4Q
.

Switching from node v12.3.1 to v8.16.0 with nvm solved this for me.
Thanks @belvederef :tada:

used nvm and downgraded to node v11.10.0, which solved my problem

I always have a problem to rebuild a old ember app despite a yarn.lock because of this package, unacceptable...

@woprandi: The system itself differs from the one where the bindings compilation worked,
so it fails, this shouldn't happen, but this package has this kind of issue.
You could try to install the app dependencies inside a VM/container that runs on an older *nix distribution (from which you know that it worked in the past) and hopefully it compiles.

Only @punitnathani's solution worked for me. Downgrade from<EMAIL_ADDRESS>to
npm install -g<EMAIL_ADDRESS>

For me as well @pthornhi . I had spent, probably, a few days for experiments...

Follow these steps to resolve the issue.
1: Make sure you have build-tools installed.
2: Update node-gyp
3: Delete package-lock.json and node modules folder and run npm install again.
4: Deleting ~/.node-gyp folder and run npm install again.
Source: https://codeforgeek.com/make-failed-with-exit-code-2/

For those who are using AMI 2, I resolve it using
sudo yum groupinstall "Development Tools"
Since my errors were
make: Entering directory `/home/www/tieza-queue/notification/node_modules/fibers/build'
  CXX(target) Release/obj.target/fibers/src/fibers.o
make: g++: Command not found
make: *** [Release/obj.target/fibers/src/fibers.o] Error 127
make: Leaving directory `/home/www/tieza-queue/notification/node_modules/fibers/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/ec2-user/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 4.14.114-105.126.amzn2.x86_64
gyp ERR! command "/home/ec2-user/.nvm/versions/node/v10.15.3/bin/node" "/home/ec2-user/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
gyp ERR! cwd /home/www/tieza-queue/notification/node_modules/fibers
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-gyp exited with code: 1
Please make sure you are using a supported platform and node version. If you
would like to compile fibers on this machine please make sure you have setup your
build environment--
Windows + OS X instructions here: https://github.com/nodejs/node-gyp
Ubuntu users please run: `sudo apt-get install g++ build-essential`
Alpine users please run: `sudo apk add python make g++`
sh: nodejs: command not found
npm WARN<EMAIL_ADDRESS>requires a peer of<EMAIL_ADDRESS>but none is installed. You must install peer dependencies yourself.
npm WARN<EMAIL_ADDRESS>No description
npm WARN<EMAIL_ADDRESS>No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY<EMAIL_ADDRESS>(node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for<EMAIL_ADDRESS>wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR<EMAIL_ADDRESS>install: `node build.js || nodejs build.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the<EMAIL_ADDRESS>install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ec2-user/.npm/_logs/2019-06-20T07_19_19_837Z-debug.log

@pthornhi its worked for me.

I am getting below error while installing btlejuice.
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 4.19.0-kali4-amd64
gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/btlejuice/node_modules/bluetooth-hci-socket
gyp ERR! node -v v10.15.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

Gotta love hundreds of people checking in on a closed issue to no avail. Good maintainer ethics!

This page is for that specific issue from 3yrs ago, which was solved. It is not catch-all place for all node-gyp failures. If you have issues with building a node module:

open an issue in that module issue tracker,
if that does not help and you are suspecting issue with node-gyp itself, open new issue here with your specific system config and error message