Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR! stack TypeError: tar.extract is not a functionnpm #2067

Closed
chaossmiling opened this issue Mar 10, 2020 · 9 comments
Closed

ERR! stack TypeError: tar.extract is not a functionnpm #2067

chaossmiling opened this issue Mar 10, 2020 · 9 comments
Labels

Comments

@chaossmiling
Copy link

chaossmiling commented Mar 10, 2020

  • Node Version: node: 12.16.1 npm: 6.13.4
  • Platform: Windows 10 x64
  • Compiler: msbuild 15.9.20
  • Module: opencv4nodejs
Verbose output (from npm or node-gyp):
npm i opencv4nodejs

> opencv4nodejs@5.5.0 install F:\electron\final\node_modules\opencv4nodejs
> node ./install/install.js

info the following opencv4nodejs environment variables are set in the package.json: 
info disableAutoBuild: 1
info opencvIncludeDir: F:\opencv\opencv\build\include
info opencvLibDir: F:\opencv\opencv\build\x64\vc15\lib
info opencvBinDir: F:\opencv\opencv\build\x64\vc15\bin
info install using lib dir: F:/opencv/opencv/build/x64/vc15/lib
info install found the following libs:
info install world : F:\opencv\opencv\build\x64\vc15\lib\opencv_world420.lib

info install setting the following defines:
info defines OPENCV4NODEJS_FOUND_LIBRARY_WORLD

info install setting the following includes:
info includes F:/opencv/opencv/build/include

info install setting the following libs:
info libs F:/opencv/opencv/build/x64/vc15/lib/opencv_world420.lib
info install spawning node gyp process: node-gyp rebuild --jobs max

F:\electron\final\node_modules\opencv4nodejs>if not defined npm_config_node_gyp (node "F:\node\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild --jobs max )  else (node "F:\node\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild --jobs max ) 
gyp ERR! UNCAUGHT EXCEPTION 
gyp ERR! stack TypeError: tar.extract is not a function
gyp ERR! stack     at Request.<anonymous> (F:\node\node_modules\npm\node_modules\node-gyp\lib\install.js:198:22)
gyp ERR! stack     at Request.emit (events.js:323:22)
gyp ERR! stack     at Request.onRequestResponse (F:\node\node_modules\npm\node_modules\request\request.js:1066:10)
gyp ERR! stack     at ClientRequest.emit (events.js:311:20)
gyp ERR! stack     at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:603:27)
gyp ERR! stack     at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
gyp ERR! stack     at TLSSocket.socketOnData (_http_client.js:476:22)
gyp ERR! stack     at TLSSocket.emit (events.js:311:20)
gyp ERR! stack     at addChunk (_stream_readable.js:294:12)
gyp ERR! stack     at readableAddChunk (_stream_readable.js:275:11)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "F:\\node\\node.exe" "F:\\node\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--jobs" "max"
gyp ERR! cwd F:\electron\final\node_modules\opencv4nodejs
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v5.0.5
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>
ERR! Error: Command failed: node-gyp rebuild --jobs max
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack TypeError: tar.extract is not a function
gyp ERR! stack     at Request.<anonymous> (F:\node\node_modules\npm\node_modules\node-gyp\lib\install.js:198:22)
gyp ERR! stack     at Request.emit (events.js:323:22)
gyp ERR! stack     at Request.onRequestResponse (F:\node\node_modules\npm\node_modules\request\request.js:1066:10)
gyp ERR! stack     at ClientRequest.emit (events.js:311:20)
gyp ERR! stack     at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:603:27)
gyp ERR! stack     at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
gyp ERR! stack     at TLSSocket.socketOnData (_http_client.js:476:22)
gyp ERR! stack     at TLSSocket.emit (events.js:311:20)
gyp ERR! stack     at addChunk (_stream_readable.js:294:12)
gyp ERR! stack     at readableAddChunk (_stream_readable.js:275:11)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "F:\\node\\node.exe" "F:\\node\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--jobs" "max"
gyp ERR! cwd F:\electron\final\node_modules\opencv4nodejs
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v5.0.5
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>

At first, I used node-gyp to install/rebuild opencv4nodejs when my node version was 10. It worked well but when I'd like to use opencv4nodejs in electron, I was told that opencv4nodejs's NODE_MODULE_VERSION is NOT match. So I upgraded my node to 12.16.1, wanted to rebuild it again, and it alerted above.

I have reinstall node-gyp for several times.

It's strange that I have install node-gyp@6.1.0 and I check the version in node_modules. But when i try to install opencv4nodejs or rebuild it, I was told my node-gyp version is 5.0.5.

@rvagg
Copy link
Member

rvagg commented Mar 10, 2020

so, every time I've seen this tar.extract error it's due to having a poorly configured Node.js and/or npm install. There's a good chance that old files weren't overwritten or deleted properly during an upgrade (or downgrade!). What you'll need to do is remove your old install completely and start again. Find wherever npm is installed globally and remove it. If you don't have anything sensitive installed, find your global node_modules directory and delete that entirely. Don't just rely on the Windows uninstaller to do this properly.
Then download install Node.js from scratch.

@bzoz
Copy link
Contributor

bzoz commented Mar 11, 2020

Tested, could not reproduce.

@chaossmiling could you follow up on @rvagg suggestion of uninstalling Node completely and reinstalling it from scratch?

@bzoz
Copy link
Contributor

bzoz commented Apr 2, 2020

No follow up, closing.

@bzoz bzoz closed this as completed Apr 2, 2020
@cclauss
Copy link
Contributor

cclauss commented Apr 2, 2020

This is a persistent problem:

It's strange that I have install node-gyp@6.1.0 and I check the version in node_modules. But when i try to install opencv4nodejs or rebuild it, I was told my node-gyp version is 5.0.5.

What is the best way to find versions of all installed node-gyp instances?
What is the best way to upgrade the node-gyp v5.0.5 instance in the above case?

@CaptainCodex
Copy link

For me, this went away after I stopped using Verdaccio registry mirror on a different architecture machine then removed all of anything node related (Debian/Raspbian) using the following guide.

I think node-gyp would know what version tarball-extract to use naturally unless interrupted by using multiple registry/architecture sources.

@scil
Copy link

scil commented May 4, 2021

I had the same error gyp ERR! stack TypeError: tar.extract is not a function while yarn add ffi-napi

I manually installed tart, then remove it, then everthing ok.

yarn add tar
yarn remove tar

@languy
Copy link

languy commented May 28, 2021

I had the same error on windows 10. Reinstalling nodejs and deleting C:\Users\username\AppData\Roaming\npm (where the global node_modules is located) didn't work for me.
Removing C:\Users\username\AppData\Roaming\nvm fixed it for me.

@himsgupta1122
Copy link

I am still facing this issue when I am using tar package. Any resolution.

   │ERROR TypeError: _tar.Extract is not a constructor

@cclauss
Copy link
Contributor

cclauss commented Apr 14, 2023

Are you using tar v6.1.13? https://www.npmjs.com/package/tar

Which of the suggestions above have you tried?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants