简体   繁体   English

尝试在 windows 10 上安装 node-ffi 会出现错误:error C2660: 'v8::FunctionTemplate::GetFunction': function does not take 0 arguments

[英]trying to install node-ffi on windows 10 gives error: error C2660: 'v8::FunctionTemplate::GetFunction': function does not take 0 arguments

I'm trying to install node-ffi as a package in one of my electron applications.我正在尝试在我的 electron 应用程序之一中将 node-ffi 安装为 package。 doing a straight " npm install node-ffi" failed... so I ended up trying the "Source Install" section found here:直接执行“npm install node-ffi”失败...所以我最终尝试了此处的“源安装”部分:

  https://github.com/node-ffi/node-ffi

What I've Done So Far:到目前为止我做了什么:

  npm install --global windows-build-tools

This created the following folder:这创建了以下文件夹:

PS C:\Users\jmk\.windows-build-tools> dir
Directory: C:\Users\jmk\.windows-build-tools


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        2020-09-23  10:15 AM                python27
-a----        2020-09-23  10:15 AM       20246528 python-2.7.15.amd64.msi
-a----        2020-09-23  11:06 AM          51992 python-log.txt
-a----        2020-09-23  10:15 AM        1119848 vs_BuildTools.exe

As yo u can see it installed python2 but I changed the default python that node-gyp uses like so:如您所见,它安装了 python2,但我更改了 node-gyp 使用的默认值 python,如下所示:

PS C:\Users\jmk\source\github\node-ffi> npm config set python C:\Python38\python.exe

And then confirmed like so:然后像这样确认:

nPS C:\Users\jmk\source\github\node-ffi> node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp@7.1.0
gyp info using node@12.18.4 | 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.30503.244) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional"
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\\jmk\\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   'C:\\Users\\jmk\\source\\github\\node-ffi\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\jmk\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\jmk\\AppData\\Local\\node-gyp\\Cache\\12.18.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=C:\\Users\\jmk\\AppData\\Local\\node-gyp\\Cache\\12.18.4',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\jmk\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\jmk\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\12.18.4\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\jmk\\source\\github\\node-ffi',
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:\\Users\\jmk\\source\\github\\node-ffi\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info ok
PS C:\Users\jmk\source\github\node-ffi>

now when i do a "node-gyp build" or rebuild, i see errors like:现在,当我进行“node-gyp 构建”或重建时,我看到如下错误:

C:\Users\jmk\source\github\node-ffi\src\ffi.cc(49,57): error C2660: 'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [C:\Users\jmk\source\github\node-ffi\build\ffi_bindings.vcxproj]
C:\Users\jmk\AppData\Local\node-gyp\Cache\12.18.4\include\node\v8.h(6126,46): message : see declaration of 'v8::FunctionTemplate::GetFunction' (compiling source file ..\src\ffi.cc) [C:\Users\jmk\source\github\node-ffi\build\ffi_bin 
dings.vcxproj]
C:\Users\jmk\source\github\node-ffi\src\ffi.cc(48,8): error C2661: 'Nan::Set': no overloaded function takes 2 arguments [C:\Users\jmk\source\github\node-ffi\build\ffi_bindings.vcxproj]
C:\Users\jmk\source\github\node-ffi\src\ffi.cc(51,60): error C2660: 'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [C:\Users\jmk\source\github\node-ffi\build\ffi_bindings.vcxproj]
C:\Users\jmk\AppData\Local\node-gyp\Cache\12.18.4\include\node\v8.h(6126,46): message : see declaration of 'v8::FunctionTemplate::GetFunction' (compiling source file ..\src\ffi.cc) [C:\Users\jmk\source\github\node-ffi\build\ffi_bin 
dings.vcxproj]
C:\Users\jmk\source\github\node-ffi\src\ffi.cc(50,8): error C2661: 'Nan::Set': no overloaded function takes 2 arguments [C:\Users\jmk\source\github\node-ffi\build\ffi_bindings.vcxproj]
C:\Users\jmk\source\github\node-ffi\src\ffi.cc(53,54): error C2660: 'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [C:\Users\jmk\source\github\node-ffi\build\ffi_bindings.vcxproj]
C:\Users\jmk\AppData\Local\node-gyp\Cache\12.18.4\include\node\v8.h(6126,46): message : see declaration of 'v8::FunctionTemplate::GetFunction' (compiling source file ..\src\ffi.cc) [C:\Users\jmk\source\github\node-ffi\build\ffi_bin 
dings.vcxproj]
C:\Users\jmk\source\github\node-ffi\src\ffi.cc(52,8): error C2661: 'Nan::Set': no overloaded function takes 2 arguments [C:\Users\jmk\source\github\node-ffi\build\ffi_bindings.vcxproj]
C:\Users\jmk\source\github\node-ffi\src\ffi.cc(55,59): error C2660: 'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [C:\Users\jmk\source\github\node-ffi\build\ffi_bindings.vcxproj]
C:\Users\jmk\AppData\Local\node-gyp\Cache\12.18.4\include\node\v8.h(6126,46): message : see declaration of 'v8::FunctionTemplate::GetFunction' (compiling source file ..\src\ffi.cc) [C:\Users\jmk\source\github\node-ffi\build\ffi_bin
dings.vcxproj]
C:\Users\jmk\source\github\node-ffi\src\ffi.cc(54,8): error C2661: 'Nan::Set': no overloaded function takes 2 arguments [C:\Users\jmk\source\github\node-ffi\build\ffi_bindings.vcxproj]

I tried to track down the first error.我试图找出第一个错误。 This is what ffi.cc(49,57) looks like:这就是 ffi.cc(49,57) 的样子:

Nan::New<FunctionTemplate>(FFIPrepCif)->GetFunction());

And this is what C:\Users\jmk\AppData\Local\node-gyp\Cache\12.18.4\include\node\v8.h(6126,46) looks like这就是 C:\Users\jmk\AppData\Local\node-gyp\Cache\12.18.4\include\node\v8.h(6126,46) 的样子

  /** Returns the unique function instance in the current execution context.*/
  V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
      Local<Context> context);

So it seems the new version of v8 requires that GetFunction be passed a context?所以似乎新版本的 v8 要求 GetFunction 被传递一个上下文? not sure.不确定。 I'm not JS programmer nor C++ programmer.我不是 JS 程序员,也不是 C++ 程序员。 I thought if it was something simple, like installing some new library?我想这是否简单,比如安装一些新库?

https://github.com/node-ffi/node-ffi/tree/master/src is the code I'm essentially dealing with at this point. https://github.com/node-ffi/node-ffi/tree/master/src是我此时主要处理的代码。

Can you point me in the right direction please?你能指出我正确的方向吗?

thanks.谢谢。

Node-ffi is no longer maintained and doesn't work with Node versions > 10, use node-ffi-napi instead. Node-ffi 不再维护并且不适用于 Node 版本 > 10,请改用node-ffi-napi There are a number of related packages that are also no longer maintained and have napi functioning forks (eg ref-napi, ref-wchar-napi).有许多相关的包也不再维护并且具有 napi 功能分支(例如 ref-napi、ref-wchar-napi)。

The old packages and the napi forks have the same API as far as I can tell, so you just need to install the new versions and change the imports in your code and it should install and run.据我所知,旧包和 napi 分支具有相同的 API,因此您只需要安装新版本并更改代码中的导入,它应该会安装并运行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C ++错误C2660:函数没有3个参数 - C++ Error C2660: Function does not take 3 arguments 奇怪的错误c2660“函数不带1个参数” - Strange error c2660 “function does not take 1 arguments” 错误C2660:&#39;Aba :: f&#39;:函数未使用0个参数 - error C2660: 'Aba::f' : function does not take 0 arguments 错误C2660:函数没有2个参数C ++ - Error C2660: function does not take 2 arguments C++ 错误C2660:&#39;MouseListener :: MousePressed&#39;:函数未采用4个参数 - error C2660: 'MouseListener::MousePressed' : function does not take 4 arguments C ++中的特征库给出错误C2660:&#39;Eigen :: MatrixBase <Derived> :: eigenvalues&#39;:函数不带2个参数 - eigen library in C++ gives error C2660: 'Eigen::MatrixBase<Derived>::eigenvalues' : function does not take 2 arguments 简短版本:错误14错误C2660:“ Player :: addSpell”:函数未采用1个参数 - Short version: Error 14 error C2660: 'Player::addSpell' : function does not take 1 arguments 错误 C2660: 'std::allocator<char> ::allocate': function 不占用 2 arguments</char> - error C2660: 'std::allocator<char>::allocate': function does not take 2 arguments 如何解决“C2660 &#39;SWidget::Construct&#39;:函数不接受 1 个参数”? - How to resolve "C2660 'SWidget::Construct': function does not take 1 arguments"? 调用可变参数模板函数会在Visual Studio 2015中给出错误C2660 - Calling a variadic template function gives error C2660 in Visual Studio 2015
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM