node-gyp: gyp ERR! stack TypeError: tar.extract is not a function
$ 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 node-gyp@5.0.3
gyp info using node@10.14.2 | 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?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 19 (4 by maintainers)
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).
/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 withnpm install -g
which will be dangling symlinks to subdirectories of that directory, look in thebin
with the same root, so/usr/local/bin/
or/usr/bin
and look for symlinks that havenode_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.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.Sure, just mark issues as “closed” even if they aren’t resolved, that makes the problems magically disappear…
This issue should be reopened, I spent one working day on this bug! Can’t find a way to resolve!
macOS Catalina is not yet released and not yet supported.
Actually I re-installed npm and it is now working.
This was the problem with
n
for me as well. It creates a mess with npm dependencies. I have fixed the issue with manually installing the appropriate npm for the version of node that I use (14.18.0). In my case the npm I need is 6.14.15.To fix npm (this example is for my node - check the npm version you need for your node):
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
I resolved it with reinstall node. I think that node-gyp was broken after mac os upgrade.