Where are node-gyp's [options] documented? - node-gyp

node-gyp --help says:
Usage: node-gyp <command> [options]
where <command> is one of:
- build - Invokes `make` and builds the module
- clean - Removes any generated build files and the "out" dir
- configure - Generates a Makefile for the current module
- rebuild - Runs "clean", "configure" and "build" all at once
- install - Install node development files for the specified node version.
- list - Prints a listing of the currently installed node development files
- remove - Removes the node development files for the specified version
node-gyp#1.0.2 /usr/local/lib/node_modules/node-gyp
node#1.8.1
But where are the [options] actually documented? I've picked through various .js source files to try to figure it out and have come up with nothing.
Do [options] just pass-thru to gyp?
Specifically, I'm trying to use a bindings file that is not named 'binding.gyp' but it seems like the node -> Python wrapper that sits between node.js and gyp doesn't allow it due to some hard-coding (as best as I can figure out).
For example: node-gyp configure custom.gyp produces:
<snip>
gyp info spawn python
gyp info spawn args [ '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp', <-- NOT OK
gyp info spawn args 'custom.gyp', <-- OK
<snip>
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/node-gyp/custom.gypi', <-- MAYBE OK? DON'T LIKE IT BEING GLOBAL (race condition here...)
<snip>
gyp: binding.gyp not found (cwd: <snip>) while trying to load binding.gyp
gyp ERR! configure error <-- YES because it doesn't exist, I want to use 'custom.gyp'
gyp ERR! stack Error: `gyp` failed with exit code: 1
<snip>
where <snip> just represents me deleting irrelevant information.
Maybe I can get around it by modifying the Python wrapper itself, but is there some other way? Some node-gyp --option=x for instance?

Looks like there is now quite a bit of documentation for this at the node-gyp repo.

Node-gyp is not quite well documented, so statements below are my findings from the project sources.
Options for node-gyp are depended on command. These options are listed in configDefs object. Some of them are translated into GYP options, others are not.
GYP file name binding.gyp is hard-coded in configure.js
GYP options probably may be set in GYP_* environment variables before node-gyp invocation. Please refer GYP command-line help and sources, since GYP is not well documented too.

Related

yarn - installation of deasync fails

When I create a react app on Windows with node 15 like this:
yarn create react-app my-project --template typescript
It fails with
yarn create v1.22.11
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents#1.2.9: The platform "win32" is incompatible with this module.
info "fsevents#1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents#2.0.6: The platform "win32" is incompatible with this module.
info "fsevents#2.0.6" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[-/4] ⠁ waiting...
[-/4] ⠁ waiting...
[3/4] ⠂ deasync
error C:\Users\teyc\AppData\Local\Yarn\Data\global\node_modules\deasync: Command failed.
Exit code: 1
Command: node ./build.js
Arguments:
Directory: C:\Users\teyc\AppData\Local\Yarn\Data\global\node_modules\deasync
Output:
C:\Users\teyc\AppData\Local\Yarn\Data\global\node_modules\deasync>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\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 info using node-gyp#7.1.2
gyp info using node#15.0.1 | win32 | x64
gyp info find Python using Python version 3.7.3 found at "C:\Users\teyc\AppData\Local\Programs\Python\Python37-32\python.exe"
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS checking VS2019 (16.8.30717.126) found at:
I don't want to install compilers. Are there binaries available for downloading?
Unfortunately, the deasync node package might not contain every binary for your node version and operating system, and yarn for some inexplicable reason requires it when running create react-app while npx doesn't.
Your options are:
Figure out how to download the prebuilt binaries into your system
https://github.com/abbr/deasync-bin
use npx
npx create react-app my-project --template typescript
use yarn 2. This is the method I prefer as it consumes less disk space
yarn set version berry
yarn create react-app myproject --template typescript

Installing electron with jitsi-meet-electron repo

I have downloaded the jitsi-meet-electron repo for building desktop app from https://github.com/jitsi/jitsi-meet-electron.git
Now, when I am trying to install electron using yarn, I am getting the below error.I think the problem is with the robotjs module.Also, for the python version - the logs shown is 'gyp info find Python using Python version 2.7.12 found at "/usr/bin/python" '
k#k-Lenovo-G50-70:~/17_2_21/jitsi-meet-electron$ yarn add electron
yarn add v1.22.10
warning ../package.json: No license field
info No lockfile found.
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
warning electron-packager > electron-download > nugget > request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning electron-packager > asar > mksnapshot > request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning electron-packager > electron-download > nugget > request > har-validator#5.1.5: this library is no longer supported
warning electron-rebuild > node-gyp > request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning eslint > file-entry-cache > flat-cache > circular-json#0.3.3: CircularJSON is in maintenance only, flatted is its successor.
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[1/6] ⡀ robotjs
[-/6] ⡀ waiting...
[-/6] ⡀ waiting...
[-/6] ⡀ waiting...
error /home/k/17_2_21/jitsi-meet-electron/node_modules/robotjs: Command failed.
Exit code: 1
Command: prebuild-install || node-gyp rebuild
Arguments:
Directory: /home/k/17_2_21/jitsi-meet-electron/node_modules/robotjs
Output:
prebuild-install WARN install No prebuilt binaries found (target=14.15.4 runtime=node arch=x64 libc= platform=linux)
gyp info it worked if it ends with ok
gyp info using node-gyp#5.1.0
gyp info using node#14.15.4 | linux | x64
gyp info find Python using Python version 2.7.12 found at "/usr/bin/python"
gyp info spawn /usr/bin/python
gyp info spawn args [
gyp info spawn args '/usr/lib/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 'make',
gyp info spawn args '-I',
gyp info spawn args '/home/k/17_2_21/jitsi-meet-electron/node_modules/robotjs/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/k/.cache/node-gyp/14.15.4/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/k/.cache/node-gyp/14.15.4',
gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/home/k/.cache/node-gyp/14.15.4/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/home/k/17_2_21/jitsi-meet-electron/node_modules/robotjs',
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 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/k/17_2_21/jitsi-meet-electron/node_modules/robotjs/build'
CXX(target) Release/obj.target/robotjs/src/robotjs.o
cc1plus: warning: command line option ‘-Wbad-function-cast’ is valid for C/ObjC but not for C++
In file included from ../src/keypress.h:6:0,
from ../src/robotjs.cc:7:
../src/keycode.h:112:23: fatal error: X11/Xutil.h: No such file or directory
compilation terminated.
robotjs.target.mk:130: recipe for target 'Release/obj.target/robotjs/src/robotjs.o' failed
make: Leaving directory '/home/k/17_2_21/jitsi-meet-electron/node_modules/robotjs/build'
make: *** [Release/obj.target/robotjs/src/robotjs.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Linux 4.15.0-133-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/k/17_2_21/jitsi-meet-electron/node_modules/robotjs
I found a way out.Below are the steps:
k#k-Lenovo-G50-70:~/26_2_21/ti$ git clone https://github.com/jitsi/jitsi-meet-electron.git
k#k-Lenovo-G50-70:~/26_2_21/ti$ ls
jitsi-meet-electron
k#k-Lenovo-G50-70:~/26_2_21/ti$ cd jitsi-meet-electron
https://github.com/jitsi/jitsi-meet-electron-utils
NOTE: For Linux install libxtst-dev and libpng++-dev (sudo apt-get install libxtst-dev libpng++-dev). This dependancies are related to RobotJS which is a dependency of jitsi-meet-electron-utils. You can see the build instructions for RobotJS here
k#k-Lenovo-G50-70:~/26_2_21/ti/jitsi-meet-electron$ sudo apt-get install libxtst-dev libpng++-dev
k#k-Lenovo-G50-70:~/26_2_21/ti/jitsi-meet-electron$ npm install
Finally, for the desktop app to run,
k#k-Lenovo-G50-70:~/17_2_21/repos/a_21_2_21$ npm start
jitsi-meet-electron#2.4.2 start /home/k/17_2_21/repos/a_21_2_21
webpack --config ./webpack.main.js --mode development && concurrently "npm:watch" "electron ./build/main.js"
I found a way out.Below are the steps:
k#k-Lenovo-G50-70:~/26_2_21/ti$ git clone https://github.com/jitsi/jitsi-meet-electron.git
k#k-Lenovo-G50-70:~/26_2_21/ti$ ls
jitsi-meet-electron
k#k-Lenovo-G50-70:~/26_2_21/ti$ cd jitsi-meet-electron
Reference link for installing additional dependencies is:
https://github.com/jitsi/jitsi-meet-electron-utils
The link mentions the below packages to be installed.
NOTE: For Linux install libxtst-dev and libpng++-dev (sudo apt-get install libxtst-dev libpng++-dev). This dependancies are related to RobotJS which is a dependency of jitsi-meet-electron-utils. You can see the build instructions for RobotJS here
k#k-Lenovo-G50-70:~/26_2_21/ti/jitsi-meet-electron$ sudo apt-get install libxtst-dev libpng++-dev
k#k-Lenovo-G50-70:~/26_2_21/ti/jitsi-meet-electron$ npm install
Finally, for the desktop app to run,
k#k-Lenovo-G50-70:~/17_2_21/repos/a_21_2_21$ npm start
jitsi-meet-electron#2.4.2 start /home/k/17_2_21/repos/a_21_2_21 webpack --config ./webpack.main.js --mode development && concurrently "npm:watch" "electron ./build/main.js"

libstdc++ is deprecated; move to libc++ when installing Babel using npm on Catalina

my error output looks like this:
> node-gyp rebuild
SOLINK_MODULE(target) Release/.node
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: library not found for -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Release/.node] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:219:12)
gyp ERR! System Darwin 19.4.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/simonhurst/PycharmProjects/supervalet/node_modules/fsevents
gyp ERR! node -v v6.17.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
When running
npm i -D #babel/core babel-loader #babel/preset-env #babel/preset-react babel-plugin-transform-class-properties
Now I can see the issue is here :
library not found for -lstdc++
However have zero idea how to resolve it.
Been searching the web and stackoverflow - messing around with uninstalling Xcode reinstalling exode looking hombrew... etc but as of yet absolutely no joy.
I'm Python dev by trade so node is most certainly not my expertise. If someone could shed some light on how to resolve this issue that would be wonderful. I can't believe I'm the only one having it.
Thanks
Wow after reading many posts and many issues on GitHub... the solution in my case wasn't making sure I had Xcode installed, and the corresponding command line tools installed and making sure I'd accepted the Apple Licence agreement. It was simply a question of updating the version of node that I was using. In my case I was using version 6.x this was the version that came pre-installed on my brand new mac. Annoying. Visit https://nodejs.org/en/ to upgrade your node version. At the time of writing this the versions I upgraded to was 12.16.1 - in the event that's helpful to a future reader of this question 'n answer session :)
Really feel the error message could have been way more helpful here, but hey that's how things are some times.

Installing Karma failed

Tried to install Karma
npm install -g karma
A warning is produced
npm WARN optional dep failed, continuing fsevents#0.3.5
At the end it seems there is no Karma installed
karma init karma.config.js
'karma' is not recognized as an internal or external command (so a windows installation).
However there seems to be a karma in
C:\Users\Me\AppData\Roaming\npm\node_modules\karma
and a builerror.log file
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at failNoPython (c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:103:14)
gyp ERR! stack at c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:64:11
gyp ERR! stack at Object.oncomplete (evalmachine.<anonymous>:108:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "c:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Me\AppData\Roaming\npm\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws
gyp ERR! node -v v0.10.36
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok
Do I need to install python in order to work with karma or is something else wrong? Thanks in advance for any help!
You need to install the command line interface so that karma will be recognised:
npm install -g karma-cli
Karma Installaltion Guide
The node-gyp error is because python isn't installed. To avoid that error follow the following steps:
Install python (v2.7.10 recommended, v3.x.x is not supported): http://www.python.org/getit/windows/
Make sure that you have a PYTHON environment variable, and it is set to drive:\path\to\python.exe not to a folder
Install Visual Studio
Windows XP/Vista/7:
- Microsoft Visual Studio C++ 2013 (Express version works well)
- If the install fails, try uninstalling any C++ 2010 x64&x86
Redistributable that you have installed first
- If you get errors that the 64-bit compilers are not installed you may
also need the compiler update for the Windows SDK 7.1
Windows 7/8:
- Microsoft Visual Studio C++ 2013 for Windows Desktop (Express version
works well)
Windows 10:
- Install Visual Studio Community 2015 Edition. (Custom Install, Select
Visual C++ during the installation)
- Set the environment variable GYP_MSVS_VERSION=2015
- Run the command prompt as Administrator
If the above steps have not worked or you are unsure please visit http://www.serverpals.com/blog/building-using-node-gyp-with-visual-studio-express-2015-on-windows-10-pro-x64 for a full walkthrough
All Windows Versions
- For 64-bit builds of node and native modules you will also need the
Windows 7 64-bit SDK
You may need to run one of the following commands if your build complains about WindowsSDKDir not being set, and you are sure you have already installed the SDK:
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x86
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x64
Source: node-gyp Github
Reference from https://stackoverflow.com/a/21366601/368997.
Karma requies node-gyp, and node-gyp has its own dependence (from the github).
Especially Windows, you need python and make sure that you have a PYTHON environment variable.

node-gyp troubles with installation

I'm trying to install webworker-threads, a node addon that requires gyp. I followed the gyp instructions for setup, so far I'm still getting an error when trying to "rebuild":
C:\Program Files\nodejs\node_modules\webworker-threads>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild
gyp ERR! configure error
gyp ERR! stack Error: spawn ENOENT
gyp ERR! stack at errnoException (child_process.js:980:11)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:771:34)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Program Files\nodejs\node_modules\webworker-threads
gyp ERR! node -v v0.10.8
gyp ERR! node-gyp -v v0.9.5
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! not ok code 0
I'm on a Windows 7 32 bit system.
Sooo to spare some time here's my personal checklist:
Paths: node is in both user and system path. npm is in user path. Python path is set too.
Python: 2.7.3 installed at C:\Python27
VisualStudio C++ 2010 AND 2012 Express installed
node version v0.10.8
ran everything with administrator privileges
Commands executed: npm install -g node-gyp
npm install webworker-threads
Then the error appears.
Do you guys by any chance notice something I'm doing wrong?
Thanks a lot in advance for your guidance!
try npm install –msvs_version=2012. This command will ask NPM to use visual studio 2012 to build.
http://www.kevgriffin.com/specifying-visual-studio-version-in-npm-installs/
After spending a while to get this to work (for me accepted answer didn't work, for me it's just half solution) i did following:
Sadly, you must have visual studio (i installed express edition 2013 for DESKTOP)
Installed python 2.7.3 (you don't have to set any environment variables)
Run cmd as administrator and go to you project root (where is you package.json file)
First run: npm config set python C:\Python27\python.exe
Then: npm install -msvs_version=2013
The trick is in command npm config set python ...path_to_python_exe... which will be provided by npm to dependency which needs python i guess.
Got Windows 7 64 bit.
Did all the above but I still got the error which was mentioned.
What worked for me was:
Uninstall Microsoft .NET Frameworks (I got more than one version)
Open regedit and navigating to:
hkey_local_machine/software/Microsoft/MSBuild
Remove all .net versions (I got there 2 and 3.5 sub directories)
If You have OS 64 Bit repeat steps 2 & 3 for %WinDir%\SysWOW64\regedit.exe
Reinstall Microsoft .NET Framework
Hope it will spare some time for you.

Resources