EnThusiast
EnThusiast

Reputation: 11

I am trying to run npm install but it's giving me strange errors

Hi i am trying to run npm install command in a directory inside my git but it's giving me these strange looking errors. I Have full log file as well which will be uploading.

> node node-scrypt-preinstall.js


> [email protected] install C:\Users\malik\Documents\Git\cryptodoggies-base\node_modules\scrypt
> node-gyp rebuild

C:\Users\malik\Documents\Git\cryptodoggies-base\node_modules\scrypt>if not defined npm_config_node_gyp (node "C:\Users\malik\AppData\Roaming\nvm\v9.7.1\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Users\malik\AppData\Roaming\nvm\v9.7.1\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack TypeError: tar.extract is not a function
gyp ERR! stack     at Request.<anonymous> (C:\Users\malik\AppData\Roaming\nvm\v9.7.1\node_modules\npm\node_modules\node-gyp\lib\install.js:199:22)
gyp ERR! stack     at Request.emit (events.js:412:35)
gyp ERR! stack     at Request.onRequestResponse (C:\Users\malik\AppData\Roaming\nvm\v9.7.1\node_modules\npm\node_modules\request\request.js:1066:10)
gyp ERR! stack     at ClientRequest.emit (events.js:400:28)
gyp ERR! stack     at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:647:27)
gyp ERR! stack     at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
gyp ERR! stack     at TLSSocket.socketOnData (_http_client.js:515:22)
gyp ERR! stack     at TLSSocket.emit (events.js:400:28)
gyp ERR! stack     at addChunk (internal/streams/readable.js:290:12)
gyp ERR! stack     at readableAddChunk (internal/streams/readable.js:265:9)
gyp ERR! System Windows_NT 10.0.19043
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\malik\\AppData\\Roaming\\nvm\\v9.7.1\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\malik\Documents\Git\cryptodoggies-base\node_modules\scrypt
gyp ERR! node -v v14.17.5
gyp ERR! node-gyp -v v5.1.0
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>
npm WARN [email protected] No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 7
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 7
npm ERR!
npm ERR! Failed at the [email protected] 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!     C:\Users\malik\AppData\Roaming\npm-cache\_logs\2021-08-20T10_12_48_146Z-debug.log

Upvotes: 1

Views: 1859

Answers (2)

Mihai
Mihai

Reputation: 100

You have nvm… maybe try ‘nvm use 9.xx’ or some other version of node. Nvm path points to a node version 14.17 and gyp seems to want 9.xx, I presume that module is installed locally probably from a previous nvm instance.

Also keep in mind ‘nvm use ’ does not persist after closing the terminal window to the next one.

Upvotes: 0

Akasha
Akasha

Reputation: 1077

The error message says:

This is a bug in node-gyp

Try to update node-gyp

Your version of node-gyp is 5.1.0 and the latest version is 8.1.0.

Update your node-gyp package and see if this fixes the error.

If the error persists, it could be because of improper installs, as reported by issues filed on the node-gyp repo here and here.

Some of the possible reasons listed are:

  • Conflicts between installed versions, whereby one version is trying to use code from another

  • Upgrades/downgrades that didn't properly overwrite previous versions

Based on other users' feedback on the issues, the suggested solution would be:

  1. Uninstall Node, npm and nvm

  2. Make sure that all related folders have also been deleted

  3. Re-install nvm, Node and npm from scratch

Although this is not an ideal solution since it involves resetting everything, this should fix the situation.

Upvotes: 2

Related Questions