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

node-gyp rebuild is failing #2144

Closed
kosuruvarunkumar opened this issue May 31, 2020 · 31 comments
Closed

node-gyp rebuild is failing #2144

kosuruvarunkumar opened this issue May 31, 2020 · 31 comments

Comments

@kosuruvarunkumar
Copy link

  • Node Version:Node: v10.19.0 and NPM: 6.14.5
  • Platform: Ubuntu 20.04
  • Module: vscode-sqlite3
Verbose output (from npm or node-gyp):
gyp info it worked if it ends with ok
gyp info using node-gyp@6.1.0
gyp info using node@10.19.0 | linux | x64
gyp info find Python using Python version 2.7.18 found at "/usr/bin/python2"
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/share/nodejs/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/varun/Desktop/WorkSpace/vscode/node_modules/vscode-sqlite3/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/share/nodejs/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/include/nodejs/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/usr/include/nodejs',
gyp info spawn args   '-Dnode_gyp_dir=/usr/share/nodejs/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/usr/include/nodejs/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/varun/Desktop/WorkSpace/vscode/node_modules/vscode-sqlite3',
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 make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/varun/Desktop/WorkSpace/vscode/node_modules/vscode-sqlite3/build'
  ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3280000/sqlite3.c
/bin/sh: 1: python: not found
make: *** [deps/action_before_build.target.mk:13: Release/obj/gen/sqlite-autoconf-3280000/sqlite3.c] Error 127
make: Leaving directory '/home/varun/Desktop/WorkSpace/vscode/node_modules/vscode-sqlite3/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/nodejs/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 5.4.0-33-generic
gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "configure" "build"
gyp ERR! cwd /home/varun/Desktop/WorkSpace/vscode/node_modules/vscode-sqlite3
gyp ERR! node -v v10.19.0
gyp ERR! node-gyp -v v6.1.0
gyp ERR! not ok
@cclauss
Copy link
Contributor

cclauss commented May 31, 2020

Please run the following commands:

  • python3 --version
  • python --version
  • py --version

@kosuruvarunkumar
Copy link
Author

python3 --version: Python 3.8.2
python2 --version: Python 2.7.18rc1

@cclauss
Copy link
Contributor

cclauss commented May 31, 2020

Please try: NODE_GYP_FORCE_PYTHON=python3 <your command goes here>

@kosuruvarunkumar
Copy link
Author

Hi @cclauss
I tried the proposed method, but it didn't work. For python3 getting the following error, and along with that, gyp application is crashing.

gyp info it worked if it ends with ok
gyp info using node-gyp@6.1.0
gyp info using node@10.19.0 | linux | x64
gyp info find Python using Python version 3.8.2 found at "/usr/bin/python3"
gyp info spawn /usr/bin/python3
gyp info spawn args [ '/usr/share/nodejs/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/varun/Desktop/WorkSpace/vscode/node_modules/vscode-sqlite3/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/share/nodejs/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/include/nodejs/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/usr/include/nodejs',
gyp info spawn args   '-Dnode_gyp_dir=/usr/share/nodejs/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/usr/include/nodejs/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/varun/Desktop/WorkSpace/vscode/node_modules/vscode-sqlite3',
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=.' ]
Traceback (most recent call last):
  File "/usr/share/nodejs/node-gyp/gyp/gyp_main.py", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3254, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3237, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3266, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 584, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 901, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 787, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'gyp==0.1' distribution was not found and is required by the application
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/share/nodejs/node-gyp/lib/configure.js:355:16)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 5.4.0-33-generic
gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/varun/Desktop/WorkSpace/vscode/node_modules/vscode-sqlite3
gyp ERR! node -v v10.19.0
gyp ERR! node-gyp -v v6.1.0
gyp ERR! not ok 

I also tried using python2 in place of python3, getting the following response:

gyp info it worked if it ends with ok
gyp info using node-gyp@6.1.0
gyp info using node@10.19.0 | linux | x64
gyp info find Python using Python version 2.7.18 found at "/usr/bin/python2"
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/share/nodejs/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/varun/Desktop/WorkSpace/vscode/node_modules/vscode-sqlite3/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/share/nodejs/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/include/nodejs/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/usr/include/nodejs',
gyp info spawn args   '-Dnode_gyp_dir=/usr/share/nodejs/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/usr/include/nodejs/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/varun/Desktop/WorkSpace/vscode/node_modules/vscode-sqlite3',
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 make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/varun/Desktop/WorkSpace/vscode/node_modules/vscode-sqlite3/build'
  ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3280000/sqlite3.c
/bin/sh: 1: python: not found
make: *** [deps/action_before_build.target.mk:13: Release/obj/gen/sqlite-autoconf-3280000/sqlite3.c] Error 127
make: Leaving directory '/home/varun/Desktop/WorkSpace/vscode/node_modules/vscode-sqlite3/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/nodejs/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 5.4.0-33-generic
gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/varun/Desktop/WorkSpace/vscode/node_modules/vscode-sqlite3
gyp ERR! node -v v10.19.0
gyp ERR! node-gyp -v v6.1.0
gyp ERR! not ok 

FYI: I am trying to build vscode source code in my ubuntu machine.

Even if the above method would have worked, I feel it still needs consideration, as we might trigger the build n number of times and we need to give the command every time.
Thank you.

@cclauss
Copy link
Contributor

cclauss commented May 31, 2020

What is the command that you are running??

@ryzokuken @targos Does the Python 3 error relate to nodejs/gyp-next#3?
Would python3 -m pip install gyp be a useful next step?
Edit: python3 -m pip install gyp-next (see below).

@kosuruvarunkumar
Copy link
Author

I was using yarn to build vscode. The build was failing as node-gyp rebuild command for a module(vscode-sqlite3) is failing.

I also tried building that specific module using node-gyp rebuild. But the build wis failing with the error stated in the above comments.

@gengjiawen
Copy link
Member

If you are using python2, you may need to link python with python2 (using ln command).

/bin/sh: 1: python: not found

@kosuruvarunkumar
Copy link
Author

Hi @gengjiawen , if you see 4 line of the output in the first comment, it says it found python. I also created an alias python for python2. It didn't work.

@kosuruvarunkumar
Copy link
Author

Hi, do we have any update here

@cclauss
Copy link
Contributor

cclauss commented Jun 3, 2020

Do you get identical results if you use node-gyp v7.0.0 and Python 3?

If yes, then please try python3 -m pip install gyp and then try again.

Please provide the exact commands that you are typing on the command line.

@ryzokuken
Copy link
Contributor

@cclauss we don't have gyp on PyPI. This should be python3 -m pip install gyp-next.

@cclauss
Copy link
Contributor

cclauss commented Jun 3, 2020

we don't have gyp on PyPI

Someone else (Chromium Authors) does.

@ryzokuken
Copy link
Contributor

@cclauss right. I'm not sure it's worth talking to the Google OSPO in order to manage to get access to that, but I could kick off an email thread if you feel too strongly about it.

@Badestrand
Copy link

Would it be possible to change node-gyp so that it doesn't fail when there are multiple python versions installed? Or at least that it gives a reasonable error message?

I run into problems with this module every 6 months or so and it always is super frustrating and difficult to find a solution (or the problem, in the first place). And I never even used this module directly but it's a dependency for every other module out there.

@cclauss
Copy link
Contributor

cclauss commented Jul 1, 2020

@Badestrand What is wrong with the suggestion at #2144 (comment) ? Please provide the command that you are typing and a complete error log if that suggestion is not providing you with access to the Python of your choice.

@Badestrand
Copy link

Thank you @cclauss, that actually worked.

What I am getting at is that I always find it difficult to find the correct solution.

In the last few hours I had a variety of different error messages from node-gyp, by trying to install the pg-native module. The error messages were:

  • No module named ast
  • TypeError: write() argument must be str, not bytes while trying to load binding.gyp
  • gyp: Call to '/usr/bin/pg_config --libdir' returned exit status 1 while in binding.gyp. while trying to load binding.gyp (this one actually originated from a different module)

Googeling these errors took some hours and a lot of retries until I reached at this thread and discovered that I need to set NODE_GYP_FORCE_PYTHON. Inbetween there was something about upgrading node-gyp as well but couldn't find how to do it when it isn't even mentioned in the package-lock.json and not installed as global module. And as mentioned, I have errors like these from node-gyp every half year or so and on different projects.

If the Python version issue is the source of a significant portion of build fails for people then it would be a huge help if this module could test for that and display a nice error message (instead of failing with one of the ones above) or even just set NODE_GYP_FORCE_PYTHON itself so it doesn't even fail.

@cclauss
Copy link
Contributor

cclauss commented Jul 1, 2020

No module named ast

Difficult to understand because ast is a builtin Standard Library module in both Python 2 and Python 3.

TypeError: write() argument must be str, not bytes while trying to load binding.gyp

This is Python 3 ensuring that the file mode and write contents are matching data type.
Knowing the command typed, node-gyp version, and the complete error log would help us spot and fix this issue.

If the Python version issue is the source of a significant portion of build fails...

Python 2 died on 1/1/2020 so Node.js and node-gyp should drop support for legacy Python as discussed in #2093.

@jabbar86
Copy link

jabbar86 commented Oct 5, 2020

E:\Zoop\zoop-product-v0\src\node_modules\x509\build\x509.vcxproj(21,3): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1       
gyp ERR! stack     at ChildProcess.onExit (C:\Users\jabba\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Windows_NT 10.0.19041
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\jabba\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" 
gyp ERR! cwd E:\Zoop\zoop-product-v0\src\node_modules\x509 ```

Getting this any idea
node : 14
python 3.8

npm config file 

userconfig C:\Users\jabba\.npmrc
"msbuild_path = "C:\\Program\"=Files"
GYP_MSVS_VERSION = "2017"
msbuild_ = "path"
msbuild_path = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe"
msvs_version = "2019"
node_gyp = "C:\\Users\\jabba\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js"
python = "python2.7"

; globalconfig C:\Users\jabba\AppData\Roaming\npm\etc\npmrc

; builtin config undefined
prefix = "C:\\Users\\jabba\\AppData\\Roaming\\npm"

@cclauss
Copy link
Contributor

cclauss commented Oct 5, 2020

@jabbar86 Your output above contains both python 3.8 AND python = "python2.7". Perhaps force the usage of Python 3 throughout the process by following the instructions at https://github.com/nodejs/node-gyp#configuring-python-dependency

@jabbar86
Copy link

jabbar86 commented Oct 5, 2020

@cclauss No luck I think Python is not an issue. here is a full log

gyp info using node-gyp@7.1.0
gyp info using node@14.9.0 | win32 | x64
gyp info find Python using Python version 3.8.5 found at "C:\Python38\python.exe"
gyp info find VS using VS2019 (16.7.30523.141) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\Python38\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Users\\jabba\\AppData\\Roaming\\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   '-I',
gyp info spawn args   'E:\\Zoop\\zoop-product-v0\\src\\node_modules\\node-expat\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\jabba\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\jabba\\AppData\\Local\\node-gyp\\Cache\\14.9.0\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\jabba\\AppData\\Local\\node-gyp\\Cache\\14.9.0',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\jabba\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\jabba\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\14.9.0\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=E:\\Zoop\\zoop-product-v0\\src\\node_modules\\node-expat',
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   'E:\\Zoop\\zoop-product-v0\\src\\node_modules\\node-expat\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
Warning: Missing input files:
E:\Zoop\zoop-product-v0\src\node_modules\node-expat\build\deps\libexpat\..\..\..\deps\libexpat\version.c
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args   'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
E:\Zoop\zoop-product-v0\src\node_modules\node-expat\build\deps\libexpat\expat.vcxproj(21,3): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\jabba\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:194:23)gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Windows_NT 10.0.19041
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\jabba\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd E:\Zoop\zoop-product-v0\src\node_modules\node-expat

@ryzokuken
Copy link
Contributor

It seems from the log that MSBuild.exe is failing, and gyp is just bubbling up the error.

@jabbar86
Copy link

jabbar86 commented Oct 5, 2020

Hey @ryzokuken I have update the env variables now getting this error

NPM CONFIG 

metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.8 node/v14.9.0 win32 x64"

; userconfig C:\Users\jabba\.npmrc
"msbuild_path = "C:\\Program\"=Files"
GYP_MSVS_VERSION = "2017"
msbuild_ = "path"
msbuild_path = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe"
msvs_version = "2019"
node_gyp = "C:\\Users\\jabba\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js"
python = "C:\\Python38\\"

; globalconfig C:\Users\jabba\AppData\Roaming\npm\etc\npmrc

; builtin config undefined
prefix = "C:\\Users\\jabba\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe

ERROR: 
gyp info it worked if it ends with ok
gyp info using node-gyp@7.1.0
gyp info using node@14.9.0 | win32 | x64
gyp info find Python using Python version 3.8.5 found at "C:\Python38\python.exe"
gyp info find VS using VS2019 (16.7.30523.141) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\Python38\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Users\\jabba\\AppData\\Roaming\\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   '-I',
gyp info spawn args   'E:\\Zoop\\zoop-product-v0\\src\\node_modules\\x509\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\jabba\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\jabba\\AppData\\Local\\node-gyp\\Cache\\14.9.0\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\jabba\\AppData\\Local\\node-gyp\\Cache\\14.9.0',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\jabba\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\jabba\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\14.9.0\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=E:\\Zoop\\zoop-product-v0\\src\\node_modules\\x509',
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   'E:\\Zoop\\zoop-product-v0\\src\\node_modules\\x509\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args   'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
  addon.cc
  x509.cc
  win_delay_load_hook.cc
E:\Zoop\zoop-product-v0\src\node_modules\x509\node_modules\nan\nan_converters_43_inl.h(22,1): error C2664: 'v8::Local<v8::Boolean> v8::Value::ToBoolean(v8::Isolate *) const': cannot convert argument 1 from 'v8::Local<v8::Context>' to 'v8::Isolate *' (compiling source file ..\src\addon.cc) [E:\Zoop\zoop-product-v0\src\node_modules\x509\build\x509.vcxproj]
E:\Zoop\zoop-product-v0\src\node_modules\x509\node_modules\nan\nan_converters_43_inl.h(22,1): message : No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called (compiling source file ..\src\addon.cc) [E:\Zoop\zoop-product-v0\src\node_modules\x509\build\x509.vcxproj]
C:\Users\jabba\AppData\Local\node-gyp\Cache\14.9.0\include\node\v8.h(2848,18): message : see declaration of 'v8::Value::ToBoolean' (compiling source file ..\src\addon.cc) [E:\Zoop\zoop-product-v0\src\node_modules\x509\build\x509.vcxproj]
E:\Zoop\zoop-product-v0\src\node_modules\x509\node_modules\nan\nan_converters_43_inl.h(40,1): error C2664: 'bool v8::Value::BooleanValue(v8::Isolate *) const': cannot convert argument 1 from 'v8::Local<v8::Context>' to 'v8::Isolate *' (compiling source file ..\src\addon.cc) [E:\Zoop\zoop-product-v0\src\node_modules\x509\build\x509.vcxproj]
E:\Zoop\zoop-product-v0\src\node_modules\x509\node_modules\nan\nan_converters_43_inl.h(40,1): message : No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called (compiling source file ..\src\addon.cc) [E:\Zoop\zoop-product-v0\src\node_modules\x509\build\x509.vcxproj]
C:\Users\jabba\AppData\Local\node-gyp\Cache\14.9.0\include\node\v8.h(2858,8): message : see declaration of 'v8::Value::BooleanValue' (compiling source file ..\src\addon.cc) [E:\Zoop\zoop-product-v0\src\node_modules\x509\build\x509.vcxproj]
E:\Zoop\zoop-product-v0\src\node_modules\x509\node_modules\nan\nan_implementation_12_inl.h(356,37): error C2660: 'v8::StringObject::New': function does not take 1 arguments (compiling source file ..\src\addon.cc) [E:\Zoop\zoop-product-v0\src\node_modules\x509\build\x509.vcxproj]
C:\Users\jabba\AppData\Local\node-gyp\Cache\14.9.0\include\node\v8.h(5847,23): message : see declaration of 'v8::StringObject::New' (compiling source file ..\src\addon.cc) [E:\Zoop\zoop-product-v0\src\node_modules\x509\build\x509.vcxproj]
E:\Zoop\zoop-product-v0\src\node_modules\x509\node_modules\nan\nan_implementation_12_inl.h(356,60): error C2059: syntax error: ')' (compiling source file ..\src\addon.cc) [E:\Zoop\zoop-product-v0\src\node_modules\x509\build\x509.vcxproj]
E:\Zoop\zoop-product-v0\src\node_modules\x509\node_modules\nan\nan_object_wrap.h(24,5): error C2039: 'IsNearDeath': is not a member of 'Nan::Persistent<v8::Object,v8::NonCopyablePersistentTraits<T>>' [E:\Zoop\zoop-product-v0\src\node_modules\x509\build\x509.vcxproj]
          with
          [
              T=v8::Object
          ] (compiling source file ..\src\addon.cc)
E:\Zoop\zoop-product-v0\src\node_modules\x509\node_modules\nan\nan.h(1904): message : see declaration of 'Nan::Persistent<v8::Object,v8::NonCopyablePersistentTraits<T>>' [E:\Zoop\zoop-product-v0\src\node_modules\x509\build\x509.vcxproj]
          with
          [
              T=v8::Object
          ] (compiling source file ..\src\addon.cc)```

@jabbar86
Copy link

jabbar86 commented Oct 5, 2020

This works for me :)

npm install -g node-gyp

export npm_config_node_gyp=/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js

rm -rf node_modules(if already there)

npm install

@ryzokuken
Copy link
Contributor

Yeah, the previous was an error in a specific version of nan.

@ryzokuken
Copy link
Contributor

P.S. can someone with triage access please close this?

@rvagg rvagg closed this as completed Oct 5, 2020
@steveoni
Copy link

steveoni commented Jul 9, 2021

I'm sorry to re-open this, I've tried all the methods listed here, but none resolve my issue.

system: Macbook
I'm using node = v12.20.2 and npm = 7.19.1, I'm using nvm to manage two different node environments. I thought it was because of the higher version of node that's causing it, so I downgraded to v12.20.2.

with all the approaches listed here, I'm still obtaining this:

$ npm install --save @tensorflow/tfjs-node@1.2.3                                                  
npm ERR! code 1
npm ERR! path /Users/steveoni/Documents/Building-Data-Driven-Applications-with-Danfo.js-/chapter11/node_modules/@tensorflow/tfjs-node
npm ERR! command failed
npm ERR! command sh -c node scripts/install.js
npm ERR! * Downloading libtensorflow
npm ERR! 
npm ERR! * Building TensorFlow Node.js bindings
npm ERR! /Users/steveoni/Documents/Building-Data-Driven-Applications-with-Danfo.js-/chapter11/node_modules/@tensorflow/tfjs-node/scripts/install.js:157
npm ERR!       throw new Error('node-gyp rebuild failed with: ' + err);
npm ERR!       ^
npm ERR! 
npm ERR! Error: node-gyp rebuild failed with: Error: Command failed: node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@12.20.2 | darwin | x64
npm ERR! gyp info find Python using Python version 3.8.5 found at "/Users/steveoni/anaconda3/bin/python3"
npm ERR! gyp info spawn /Users/steveoni/anaconda3/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/steveoni/Documents/Building-Data-Driven-Applications-with-Danfo.js-/chapter11/node_modules/@tensorflow/tfjs-node/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/steveoni/Library/Caches/node-gyp/12.20.2/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/steveoni/Library/Caches/node-gyp/12.20.2',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/steveoni/Library/Caches/node-gyp/12.20.2/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/steveoni/Documents/Building-Data-Driven-Applications-with-Danfo.js-/chapter11/node_modules/@tensorflow/tfjs-node',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
npm ERR! No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.
npm ERR! No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
npm ERR! 
npm ERR! 
npm ERR! 
npm ERR! Traceback (most recent call last):
npm ERR!   File "/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1500, in XcodeVersion
npm ERR!     version_list = GetStdoutQuiet(["xcodebuild", "-version"]).splitlines()
npm ERR!   File "/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1563, in GetStdoutQuiet
npm ERR!     raise GypError("Error %d running %s" % (job.returncode, cmdlist[0]))
npm ERR! gyp.common.GypError: Error 1 running xcodebuild
npm ERR! 
npm ERR! During handling of the above exception, another exception occurred:
npm ERR! 
npm ERR! Traceback (most recent call last):
npm ERR!   File "/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 51, in <module>
npm ERR!     sys.exit(gyp.script_main())
npm ERR!   File "/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 670, in script_main
npm ERR!     return main(sys.argv[1:])
npm ERR!   File "/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 662, in main
npm ERR!     return gyp_main(args)
npm ERR!   File "/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 647, in gyp_main
npm ERR!     generator.GenerateOutput(flat_list, targets, data, params)
npm ERR!   File "/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 2451, in GenerateOutput
npm ERR!     writer.Write(
npm ERR!   File "/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 831, in Write
npm ERR!     self.WriteSources(
npm ERR!   File "/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 1302, in WriteSources
npm ERR!     cflags = self.xcode_settings.GetCflags(
npm ERR!   File "/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 661, in GetCflags
npm ERR!     archs = self.GetActiveArchs(self.configname)
npm ERR!   File "/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 515, in GetActiveArchs
npm ERR!     xcode_archs_default = GetXcodeArchsDefault()
npm ERR!   File "/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 122, in GetXcodeArchsDefault
npm ERR!     xcode_version, _ = XcodeVersion()
npm ERR!   File "/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1511, in XcodeVersion
npm ERR!     version = CLTVersion()  # macOS Catalina returns 11.0.0.0.1.1567737322
npm ERR!   File "/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1549, in CLTVersion
npm ERR!     return re.search(regex, output).groupdict()["version"]
npm ERR! AttributeError: 'NoneType' object has no attribute 'groupdict'
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
npm ERR! gyp ERR! System Darwin 19.6.0
npm ERR! gyp ERR! command "/Users/steveoni/.nvm/versions/node/v12.20.2/bin/node" "/Users/steveoni/.nvm/versions/node/v12.20.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/steveoni/Documents/Building-Data-Driven-Applications-with-Danfo.js-/chapter11/node_modules/@tensorflow/tfjs-node
npm ERR! gyp ERR! node -v v12.20.2
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok 
npm ERR! 
npm ERR!     at /Users/steveoni/Documents/Building-Data-Driven-Applications-with-Danfo.js-/chapter11/node_modules/@tensorflow/tfjs-node/scripts/install.js:157:13
npm ERR!     at ChildProcess.exithandler (child_process.js:315:5)
npm ERR!     at ChildProcess.emit (events.js:314:20)
npm ERR!     at maybeClose (internal/child_process.js:1022:16)
npm ERR!     at Socket.<anonymous> (internal/child_process.js:444:11)
npm ERR!     at Socket.emit (events.js:314:20)
npm ERR!     at Pipe.<anonymous> (net.js:675:12)

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/steveoni/.npm/_logs/2021-07-09T23_41_50_867Z-debug.log

@cclauss
Copy link
Contributor

cclauss commented Jul 10, 2021

@steveoni You have a different problem than the others on this issue. Please read
https://github.com/nodejs/node-gyp/blob/master/macOS_Catalina.md

@steveoni
Copy link

@cclauss thanks it works. I really appreciate your fast response. I was really frustrated. I tried different things.

Thanks once again.

@sabinasiddiqi
Copy link

@kosuruvarunkumar - did you figure out a solution? I am having the same issue with installing @vscode/sqlite3. I tried setting NODE_GYP_FORCE_PYTHON=python3 in my environment before running yarn install but no change...

@cclauss
Copy link
Contributor

cclauss commented Mar 31, 2022

Run SW_VERS on your Mac:

ProductName:	macOS
ProductVersion:	12.3
BuildVersion:	21E230

The current macOS removes Python 2 so which -a python and which -a python2 should return no hits.

If Py2 is still on your machine, then perhaps it was installed by homebrew, macports, anaconda, pyenv, etc.

@stakkdev
Copy link

Please try: NODE_GYP_FORCE_PYTHON=python3 <your command goes here>

@cclauss Thank you so much

It worked for me.

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

No branches or pull requests

10 participants