首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >试图在windows 10上安装节点-ffi会产生错误:错误C2660:'v8::FunctionTemplate::GetFunction':function不使用0参数

试图在windows 10上安装节点-ffi会产生错误:错误C2660:'v8::FunctionTemplate::GetFunction':function不使用0参数
EN

Stack Overflow用户
提问于 2020-09-23 15:23:13
回答 1查看 640关注 0票数 2

我正试图在我的电子应用程序中安装node作为一个包。直接“npm安装节点”失败.因此,我最后尝试了“”部分,在这里可以找到:

代码语言:javascript
复制
  https://github.com/node-ffi/node-ffi

我到目前为止所做的事:

代码语言:javascript
复制
  npm install --global windows-build-tools

这创建了以下文件夹:

代码语言:javascript
复制
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

yo可以看到它安装了python2,但是我更改了node使用的默认python,如下所示:

代码语言:javascript
复制
PS C:\Users\jmk\source\github\node-ffi> npm config set python C:\Python38\python.exe

然后确认如下:

代码语言:javascript
复制
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构建”或重新构建时,我会看到以下错误:

代码语言:javascript
复制
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]

我试着找出第一个错误。这就是ffi.cc(49,57)的样子:

代码语言:javascript
复制
Nan::New<FunctionTemplate>(FFIPrepCif)->GetFunction());

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

代码语言:javascript
复制
  /** Returns the unique function instance in the current execution context.*/
  V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
      Local<Context> context);

因此,新版本的v8似乎要求向GetFunction传递上下文吗?不确定。我不是JS程序员,也不是C++程序员。我想如果是简单的事情,比如安装一些新的库?

在这一点上,https://github.com/node-ffi/node-ffi/tree/master/src是我本质上处理的代码。

你能给我指出正确的方向吗?

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2022-03-21 09:53:54

如果节点-ffi不再维护。不适用于Node版本> 10,则使用节肢动物代替。有许多相关的包也不再维护,并且具有napi功能叉(例如,ref-napi,ref-wchar-napi)。

据我所知,旧包和napi分叉具有相同的API,因此您只需安装新版本并更改代码中的导入,它就应该安装和运行。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64031212

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档