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

gyp ERR! on npm/yarn install #2444

Closed
bUxEE opened this issue Jun 25, 2021 · 14 comments
Closed

gyp ERR! on npm/yarn install #2444

bUxEE opened this issue Jun 25, 2021 · 14 comments
Labels

Comments

@bUxEE
Copy link

bUxEE commented Jun 25, 2021

I encounter the following error, log says
npm ERR! gyp info using node-gyp@3.8.0
but if i use the command node-gyp -v v8.1.0 is displayed. How can i force npm to use the correct node-gyp version?

node v16.3.0
npm v7.19.0
python 3.9.5
Windows10 AMD64

npm verb stack Error: command failed
npm verb stack     at ChildProcess.<anonymous> (C:\...\AppData\Roaming\nvm\v16.3.0\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27) npm verb stack     at ChildProcess.emit (node:events:394:28)
npm verb stack     at maybeClose (node:internal/child_process:1067:16)
npm verb stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm verb pkgid node-sass@4.14.1
npm verb cwd C:\...
npm verb Windows_NT 10.0.19042
npm verb argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i" "--verbose"
npm verb node v16.3.0
npm verb npm  v7.19.0
npm ERR! code 1
npm ERR! path C:\...\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files\nodejs\node.exe C:\...\node_modules\node-sass\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
npm ERR! gyp verb cli   'C:\\...\\node_modules\\node-sass\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.3.0 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "C:\Python39\python.exe" in the PATH
npm ERR! gyp verb `which` succeeded C:\Python39\python.exe C:\Python39\python.exe
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: C:\Python39\python.exe -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack   File "<string>", line 1
npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack                       ^
npm ERR! gyp ERR! stack SyntaxError: invalid syntax
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:326:12)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1067:16)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\...\\node_modules\\node-sass\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd C:\...\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.3.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1
npm verb exit 1
npm timing npm Completed in 7816ms
npm verb code 1

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\...\AppData\Local\npm-cache\_logs\2021-06-25T09_25_53_133Z-debug.log

@cclauss
Copy link
Contributor

cclauss commented Jun 25, 2021

@bUxEE
Copy link
Author

bUxEE commented Jun 25, 2021

Thank you for your quick answer, but i am using VNM windows .
Will that guide still work?

@BasilaryGroup
Copy link

BasilaryGroup commented Jun 27, 2021

I'm running Volta. The suggested fix runs for npm < 7, but the same error appears when I run npm i to install my project packages.

> where node
C:\Program Files\Volta\node.exe
C:\Program Files\nodejs\node.exe

@cclauss
Copy link
Contributor

cclauss commented Jun 27, 2021

the same error appears

Does it still say npm ERR! gyp ERR! node-gyp -v v3.8.0?

What does npm --version return?

@BasilaryGroup
Copy link

gyp info using node-gyp@3.8.0
gyp info using node@14.17.0 | win32 | x64
> npm --version
6.14.13

@BasilaryGroup
Copy link

> node-sass@4.13.1 postinstall C:\Users\Me\Web\client\node_modules\node-sass
> node scripts/build.js

Building: C:\Users\Me\AppData\Local\Volta\tools\image\node\14.17.0\node.exe C:\Users\Me\Web\client\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   'C:\\Users\\Me\\AppData\\Local\\Volta\\tools\\image\\node\\14.17.0\\node.exe',
gyp verb cli   'C:\\Users\\Me\\Web\\client\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library='
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@14.17.0 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\Users\Me\Web\client\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Users\Me\Web\client\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Users\Me\Web\client\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Users\Me\Web\client\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Users\Me\Web\client\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\Users\Me\Web\client\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:192:21)
gyp verb `which` failed  python2 Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\Users\Me\Web\client\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Users\Me\Web\client\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Users\Me\Web\client\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Users\Me\Web\client\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Users\Me\Web\client\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\Users\Me\Web\client\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:192:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Users\Me\AppData\Local\Programs\Python\Python37\python.EXE
gyp ERR! configure error 
gyp ERR! stack Error: Command failed: C:\Users\Me\AppData\Local\Programs\Python\Python37\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:319:12)
gyp ERR! stack     at ChildProcess.emit (events.js:376:20)
gyp ERR! stack     at maybeClose (internal/child_process.js:1055:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
gyp ERR! System Windows_NT 10.0.19042
gyp ERR! command "C:\\Users\\Me\\AppData\\Local\\Volta\\tools\\image\\node\\14.17.0\\node.exe" "C:\\Users\\Me\\Web\\client\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\Me\Web\client\node_modules\node-sass
gyp ERR! node -v v14.17.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN eslint-plugin-vue@5.2.3 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN vue-eslint-parser@5.0.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN vtk.js@16.2.1 requires a peer of wslink@0.1.15 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.13.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.13.1 postinstall 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\Me\AppData\Roaming\npm-cache\_logs\2021-06-27T20_04_26_707Z-debug.log

@cclauss
Copy link
Contributor

cclauss commented Jun 27, 2021

Current npm is 7.19.0 https://www.npmjs.com/package/npm

Current node-gyp is v8.1.0. https://github.com/nodejs/node-gyp/releases v3 is out-of-date.

Node-sass is deprecated. sass/node-sass#2952

@BasilaryGroup
Copy link

BasilaryGroup commented Jun 27, 2021

I've upgrade npm to 7.19.0. I'm still seeing the same problem.

Until a few minutes ago, I didn't know node-gyp existed.

More for curiousity, how or what installed it on my machine?

@BasilaryGroup
Copy link

BasilaryGroup commented Jun 27, 2021

Ok. Upgraded npm to 7.19.0, followed the instructions https://github.com/nodejs/node-gyp/blob/master/docs/Updating-npm-bundled-node-gyp.md#windows to upgrade for Windows.

There is no sub folder node_modules\npm\node_modules\@npmcli\run-script. Instead, I was able to do the following,

$ cd node_modules\npm\node_modules\npm-lifecycle
$ npm install node-gyp@latest
$ npm list node-gyp
npm-lifecycle@3.1.4 c:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle
`-- node-gyp@8.1.0

Running npm i in my project still fails with the same error and still states I'm using node-gyp -v v3.8.0.

@cclauss
Copy link
Contributor

cclauss commented Jun 27, 2021

cd c:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle
npm install node-gyp@latest

@BasilaryGroup
Copy link

BasilaryGroup commented Jun 27, 2021

Thank you cclauss for your patience!

What a mess. For those stuck with this problem of being guilting of using older packages on your Windows development system.

  • Uninstalled Volta, it served its purpose
  • Uninstalled node 14.x
  • deleted c:\Program Files\nodejs
  • rebooted
  • installed node 14.7.1, do not select Automatically install the necessary tools.... option
  • using npm 6.14.13, node 14.17.1

At least my implementation of this problem was due to switching between numerous git branches. One of the branches was old and needed nodejs 10.x to run. My environment is now 14.x. What looked to be a node-gyp issue was simply me shooting myself in the foot trying to run an out-of-date code base, out of date package-lock.json, etc.

Rebuilding my development environment didn't hurt but I'm going to do a bit of housekeeping to remove or migrate forward my old git branches.

@cclauss
Copy link
Contributor

cclauss commented Jun 28, 2021

@bUxEE Can this issue be closed?

@bUxEE
Copy link
Author

bUxEE commented Jun 28, 2021

Last night I managed to update node-gyp in the latest node version 16.x.x inside nvm folders following your directions. This did not solve the issue but by:

  • installing via nvm a lower version of node (14.x.x) which was using node-gyp 5.x
  • completely removing all lock files and node_modules directory
  • reinstalling with yarn (NOT npm)

solved the issue

@bUxEE bUxEE closed this as completed Jun 28, 2021
@TheoOliveira
Copy link

In case someone faced, my context i was using vite with yarn, i just add to the package using the @latest tag

yarn add node-gyp@latest

@nodejs nodejs locked as resolved and limited conversation to collaborators Aug 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants