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

common.gypi not found on Windows #1371

Closed
acailly opened this issue Jan 26, 2018 · 11 comments
Closed

common.gypi not found on Windows #1371

acailly opened this issue Jan 26, 2018 · 11 comments
Labels

Comments

@acailly
Copy link

acailly commented Jan 26, 2018

  • Node Version: node v8.9.1 npm 5.5.1 installed with nvm-windows 1.1.5
  • Platform: Microsoft Windows 10 Pro Insider Preview 10.0.17074 N/A version 17074 x64-based PC
  • Compiler: Windows-Build-Tools
  • Module: node-lz4 which is used by mpl
Verbose output (from npm or node-gyp):
npm info lifecycle lz4@0.5.3~install: lz4@0.5.3

> lz4@0.5.3 install c:\_Projets\Perso\node-lz4
> node-gyp rebuild


c:\_Projets\Perso\node-lz4>if not defined npm_config_node_gyp (node "C:\Appli\nvm\v8.9.1\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'C:\\Appli\\nvm\\v8.9.1\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild' ]
gyp info using node-gyp@3.6.2
gyp info using node@8.9.1 | 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 "C:\Users\user\.windows-build-tools\python27\python.exe" in the PATH
gyp verb `which` succeeded C:\Users\user\.windows-build-tools\python27\python.exe C:\Users\user\.windows-build-tools\python27\python.exe
gyp verb check python version `C:\Users\user\.windows-build-tools\python27\python.exe -c "import platform; print(platform.python_version());"` returned: "2.7.13\r\n"
gyp verb get node dir compiling against specified --nodedir dev files: C:/Appli/nodejsgyp verb build dir attempting to create "build" dir: c:\_Projets\Perso\node-lz4\build gyp verb build dir "build" dir needed to be created? c:\_Projets\Perso\node-lz4\build gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: c:\_Projets\Perso\node-lz4\build\config.gypi
gyp verb config.gypi checking for gypi file: c:\_Projets\Perso\node-lz4\config.gypi
gyp verb common.gypi checking for gypi file: c:\_Projets\Perso\node-lz4\common.gypi
gyp verb gyp gyp format was not specified; forcing "msvs"
gyp info spawn C:\Users\user\.windows-build-tools\python27\python.exe
gyp info spawn args [ 'C:\\Appli\\nvm\\v8.9.1\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-G',
gyp info spawn args   'msvs_version=2015',
gyp info spawn args   '-I',
gyp info spawn args   'c:\\_Projets\\Perso\\node-lz4\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Appli\\nvm\\v8.9.1\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Appli\\nodejs\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:/Appli/nodejs',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Appli\\nvm\\v8.9.1\\node_modules\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\Appli\\nodejs\\$(Configuration)\\node.lib',gyp info spawn args   '-Dmodule_root_dir=c:\\_Projets\\Perso\\node-lz4',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'c:\\_Projets\\Perso\\node-lz4\\build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp: C:\Appli\nodejs\common.gypi not found (cwd: c:\_Projets\Perso\node-lz4) while reading includes of binding.gyp while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Appli\nvm\v8.9.1\node_modules\npm\node_modules\node-gyp\lib\configure.js:336:16)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 10.0.17074
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Appli\\nvm\\v8.9.1\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd c:\_Projets\Perso\node-lz4
gyp ERR! node -v v8.9.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

I tried to install mpl and had an error when rebuilding node-lz4.

I tried to clone and install node-lz4 whith the same error.

After some research I think this is caused by node-gyp looking for SDK include in C:\Appli\nodejs instead of C:\Users\user\.node-gyp where common.gypi is present

I tried to set the devdir by setting npm config set devdir C:\Users\user\.node-gyp, but this doesn't change anything.

I've reproduced this setup on another machine of mine.

@bnoordhuis
Copy link
Member

bnoordhuis commented Jan 27, 2018

Here is the cause of your issue:

gyp verb get node dir compiling against specified --nodedir dev files: C:/Appli/nodejsgyp

You are either explicitly or implicitly passing a bad --nodedir path to node-gyp. If you don't pass it on the command line, look in your .npmrc.

@acailly
Copy link
Author

acailly commented Jan 27, 2018

@bnoordhuis I am passing C:/Appli/nodejs as --nodedir value and that seems correct to me since this folder contains the node executable

Can you explain a bit more how this is related to my error?

@bnoordhuis
Copy link
Member

--nodedir should point to the node.js source tree, either from a tarball or from git, not the directory containing the binaries.

@acailly
Copy link
Author

acailly commented Jan 27, 2018

@bnoordhuis That's very confusing since the Readme says the --nodedir should contain the path to the node binary

I quickly tried with the nodedir pointing to C:\Users\user\.node-gyp\8.9.1\include\node instead of C:\Appli\nodejs and there is no more error with common.gypi, but the new error is Cannot open include file: 'node. h'.

I will try to see if I find some interesting info in existing issues.

@bnoordhuis
Copy link
Member

Oh, you're right. The documentation is simply wrong on that point. I'll get it updated.

I quickly tried with the nodedir pointing to C:\Users\user.node-gyp\8.9.1\include\node

Note that --nodedir should point to a source tree, not just the header files. If you don't pass anything to node-gyp, it figures it out on its own most of the time.

@acailly
Copy link
Author

acailly commented Jan 27, 2018

@bnoordhuis Does that means you have to get the node source tree in order to install an dependency using node-gyp??

I haven't seen that in the docs. I thought the header and the node.lib would be enough 🤔

Is it written somewhere? I would like to pin the place where it is explained in order to remember that.

Does that mean that if I have multiple node install (via nvm-windows) I should have the node source for every version?

@bnoordhuis
Copy link
Member

If you don't specify anything, node-gyp downloads the appropriate headers. If you have those installed already but in a non-standard location where node-gyp won't find them, use --devdir, not --nodedir.

@acailly
Copy link
Author

acailly commented Jan 27, 2018

OK that's exactly what I was doing first 😄

But it didn't work because for some reason node-gyp was trying to look for common.gypi in C:\Appli\nodejs

So I set the devdir to C:\Users\user\.node-gyp\8.9.1\include\node, but it didn't change anything.

So I set the nodedir to C:\Users\user\.node-gyp\8.9.1\include\node, and it changed the error.

So I set the nodedir to C:\Users\user\.node-gyp\8.9.1 and it said it was not finding the node.lib file in C:\Users\user\.node-gyp\8.9.1\Release\node.lib

In my previous message, I was at this point.

Then I looked in C:\Users\user\.node-gyp\8.9.1 and saw there was a node.lib file in the x64 folder so I created a Release folder next to it and copied the node.lib file and it worked!

But when I read your last answer I realized that maybe the source problem was that nodedir npm config was already set in the first place (I don't know why).

So I deleted devdir and nodedir in npm config and tried to install my dependency and... it worked 🎉

To sum up, nodedir was set in npm config and it should not have been the case. Thanks.

@ValeTheVioletMote
Copy link

Can confirm that --devdir didn't help. --tarball is useless because node-gyp subsequently wants to download the node.lib file, and as per #1002 there's no option to point anything to node.lib.

Here was my solution, hope to help anyone else stuck behind corporate barriers. I'm using v16.2.0 as an example, so swap with your appropriate node version.

Create a folder you're happy to house 16.2.0 data and point to it with the terminal command. I chose %USERPROFILE%\.node-gyp\16.2.0. Doesn't have to be in .node-gyp.

Create two subfolders within that folder: Release and src.

Download: https://nodejs.org/download/release/v16.2.0/win-x64/node.lib and https://nodejs.org/download/release/v16.2.0/node-v16.2.0-headers.tar.gz

Place node.lib in the Release subfolder.

Open the headers.tar.gz file. I used 7zip. Once inside the tar, navigate to include/node.

Extract the two .gypi files into your base folder.

Extract everything else into the src subfolder.

Run using --nodedir=%USERPROFILE%\.node-gyp\16.2.0 (or your equivalent folder if you differed from me)

@mpawlow
Copy link

mpawlow commented Oct 3, 2022

  • Error encountered on Windows using Node 18.10.0
PS C:\Users\Mike\git\ngp-projects-api> npm rebuild
more information.
npm ERR! code 1
npm ERR! path C:\Users\Mike\git\ngp-projects-api\node_modules\gcstats.js
npm ERR! command failed
npm ERR! command C:\windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.1.0
npm ERR! gyp info using node@18.10.0 | win32 | x64
npm ERR! gyp info find Python using Python version 3.9.7 found at "C:\Users\Mike\AppData\Local\Programs\Python\Python39\python.exe"
npm ERR! gyp http GET https://nodejs.org/download/release/v18.10.0/node-v18.10.0-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v18.10.0/node-v18.10.0-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v18.10.0/SHASUMS256.txt
npm ERR! gyp http GET https://nodejs.org/download/release/v18.10.0/win-x86/node.lib
npm ERR! gyp http GET https://nodejs.org/download/release/v18.10.0/win-x64/node.lib
npm ERR! gyp http GET https://nodejs.org/download/release/v18.10.0/win-arm64/node.lib
npm ERR! gyp http 200 https://nodejs.org/download/release/v18.10.0/SHASUMS256.txt
npm ERR! gyp WARN install got an error, rolling back install
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack FetchError: request to https://nodejs.org/download/release/v18.10.0/win-x86/node.lib failed, reason: connect ETIMEDOUT 2606:4700:10::6814:162e:443
npm ERR! gyp ERR! stack     at ClientRequest.<anonymous> (C:\Users\Mike\AppData\Local\nvs\node\18.10.0\x64\node_modules\npm\node_modules\minipass-fetch\lib\index.js:130:14)
npm ERR! gyp ERR! stack     at ClientRequest.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at TLSSocket.socketErrorListener (node:_http_client:494:9)
npm ERR! gyp ERR! stack     at TLSSocket.emit (node:events:525:35)
npm ERR! gyp ERR! stack     at emitErrorNT (node:internal/streams/destroy:151:8)
npm ERR! gyp ERR! stack     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
npm ERR! gyp ERR! stack     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
npm ERR! gyp ERR! System Windows_NT 10.0.19044
npm ERR! gyp ERR! command "C:\\Users\\Mike\\AppData\\Local\\nvs\\node\\18.10.0\\x64\\node.exe" "C:\\Users\\Mike\\AppData\\Local\\nvs\\node\\18.10.0\\x64\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\Mike\git\ngp-projects-api\node_modules\gcstats.js
npm ERR! gyp ERR! node -v v18.10.0
npm ERR! gyp ERR! node-gyp -v v9.1.0
npm ERR! gyp ERR! not ok
  • Note: Not specifying --nodedir CLI option
  • Problem is related to npm using IPv6 address that is timing out inside corporate Intranet
    • ETIMEDOUT 2606:4700:10::6814:162e:443
  • Work-around was to copy the entire existing cache directory for Node 18.9.1 to a new cache directory called 18.10.0
  • e,g,
C:\Users\Mike\AppData\Local\node-gyp\Cache\18.9.1 --> C:\Users\Mike\AppData\Local\node-gyp\Cache\18.10.0
  • Solution worked for me but doesn't seem kosher
    • I was fortunate to have an existing cache folder to copy from my old Node installation (Node 18.9.1) before upgrading to Node 18.10.0

@cclauss cclauss added the Windows label Oct 3, 2022
@lijianzhi01
Copy link

lijianzhi01 commented Dec 8, 2022

I solved this by manually download cache in windows powershell:
node "C:\Users\$($env:username)\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" install
The node-gyp.js is in global node_module.

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

6 participants