Node-gyp: gyp ERR! stack TypeError: tar.extract is not a function

Created on 5 Sep 2019  路  16Comments  路  Source: nodejs/node-gyp

$ node -v
v10.14.2

$ npm -v
6.4.1

Platform: macOS Catalina

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info find Python using Python version 2.7.15 found at "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python"
gyp http GET https://nodejs.org/download/release/v10.14.2/node-v10.14.2-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v10.14.2/node-v10.14.2-headers.tar.gz
gyp ERR! UNCAUGHT EXCEPTION 
gyp ERR! stack TypeError: tar.extract is not a function
gyp ERR! stack     at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:198:22)
gyp ERR! stack     at Request.emit (events.js:187:15)
gyp ERR! stack     at Request.onRequestResponse (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1066:10)
gyp ERR! stack     at ClientRequest.emit (events.js:182:13)
gyp ERR! stack     at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21)
gyp ERR! stack     at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
gyp ERR! stack     at TLSSocket.socketOnData (_http_client.js:442:20)
gyp ERR! stack     at TLSSocket.emit (events.js:182:13)
gyp ERR! stack     at addChunk (_stream_readable.js:283:12)
gyp ERR! stack     at readableAddChunk (_stream_readable.js:264:11)
gyp ERR! System Darwin 19.0.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure"
gyp ERR! cwd /Users/herve76/Documents/GitHub/nbt-1357/node_modules/talib
gyp ERR! node -v v10.14.2
gyp ERR! node-gyp -v v5.0.3
gyp ERR! This is a bug in `node-gyp`.
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR!     <https://github.com/nodejs/node-gyp/issues>

Any idea why?

Most helpful comment

I think this is normally a sign of mixed installs - one version is trying to use code from another - or an install that didn't properly overwrite an older install (there was a bug a while back with npm that caused this exact error because upgrading npm didn't wipe out older files and directories, leaving a jumbled mess).

  1. Clean out your global npm installs, it's going to be /usr/local/lib/node_modules or /usr/lib/node_modules - npm config get prefix shows you the first part of this and it'll depend on how Node was installed on your machine. Just blow that whole directory away because you're going to reinstall anyway. There may be global commands you installed with npm install -g which will be dangling symlinks to subdirectories of that directory, look in the bin with the same root, so /usr/local/bin/ or /usr/bin and look for symlinks that have node_modules in them and get rid of them. If you care about the things you installed globall, take not of them so you can reinstall later.
  2. Remove node, nodejs, npm, node-gyp from your system package manager (apt, dnf, yum, apk, etc.). Full purge, leave nothing, these cause too much chaos with the way npm handles dependencies.
  3. Install Node from somewhere other than your package manager, I recommend using the NodeSource distributions: https://github.com/nodesource/distributions for servers but the Snap (maintained by me) https://snapcraft.io/node for development systems (I can't understate how nice it is to have the latest version of my chosen release line without asking for it on my dev machine). You could also take a more manual approach such as https://gist.github.com/rvagg/742f811be491a49ba0b9

All 16 comments

__macOS Catalina__ is not yet released and not yet supported.

Actually I re-installed npm and it is now working.

Running into the same error with Node 12.14.0 and node-gyp 5.0.5 on OS X Mojave. Any thoughts? Node 10 builds fine.

Running in the same problem with Node v13.5.0 on Ubuntu 19.10. I can't seem to compile node myself and get npm rebuild to work.

Can this be re-opened please? Just about every build I run is failing due to this error.

Did you reinstall npm as suggested above?

I reinstalled npm and yarn both, to no avail.

I then manually globally installed a new version of node-gyp to my global npm packages and moved that to the location where it was erroring. That got me one step further.

Or maybe it was a step back. Now it's failing with even worse errors.

I think this is normally a sign of mixed installs - one version is trying to use code from another - or an install that didn't properly overwrite an older install (there was a bug a while back with npm that caused this exact error because upgrading npm didn't wipe out older files and directories, leaving a jumbled mess).

  1. Clean out your global npm installs, it's going to be /usr/local/lib/node_modules or /usr/lib/node_modules - npm config get prefix shows you the first part of this and it'll depend on how Node was installed on your machine. Just blow that whole directory away because you're going to reinstall anyway. There may be global commands you installed with npm install -g which will be dangling symlinks to subdirectories of that directory, look in the bin with the same root, so /usr/local/bin/ or /usr/bin and look for symlinks that have node_modules in them and get rid of them. If you care about the things you installed globall, take not of them so you can reinstall later.
  2. Remove node, nodejs, npm, node-gyp from your system package manager (apt, dnf, yum, apk, etc.). Full purge, leave nothing, these cause too much chaos with the way npm handles dependencies.
  3. Install Node from somewhere other than your package manager, I recommend using the NodeSource distributions: https://github.com/nodesource/distributions for servers but the Snap (maintained by me) https://snapcraft.io/node for development systems (I can't understate how nice it is to have the latest version of my chosen release line without asking for it on my dev machine). You could also take a more manual approach such as https://gist.github.com/rvagg/742f811be491a49ba0b9

This is not a feasible solution for 50 of our raspberry pi's

Is there an actual solution to this? I can't install running on ubuntu with node 12

The only solution that actually fixes this which has been offered, is to reinstall your complete system and remove anything to do with Node, npm, yarn, and start from scratch.

Understandably, this is far from an ideal solution and the fact that it's even suggested as an option is very dubious.

I managed to get it up and running on our development machines without nuking the whole environment by mucking around a lot, and manually moving some package files and ignoring a lot of errors that came up. I haven't documented exact steps, as it was a messy process.

This issue should be reopened, I spent one working day on this bug! Can't find a way to resolve!

I resolved it with reinstall node.
I think that node-gyp was broken after mac os upgrade.

Sure, just mark issues as "closed" even if they aren't resolved, that makes the problems magically disappear...

It seems problem of npm or n.
I'm not remember commands in detail but re install npm by referencing command on the comment and succeeded in installing node-gyp.
https://github.com/tj/n/issues/508#issuecomment-418295739

Was this page helpful?
0 / 5 - 0 ratings