我正试图在我的电子应用程序中安装node作为一个包。直接“npm安装节点”失败.因此,我最后尝试了“”部分,在这里可以找到:
https://github.com/node-ffi/node-ffi我到目前为止所做的事:
npm install --global windows-build-tools这创建了以下文件夹:
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.exeyo可以看到它安装了python2,但是我更改了node使用的默认python,如下所示:
PS C:\Users\jmk\source\github\node-ffi> npm config set python C:\Python38\python.exe然后确认如下:
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构建”或重新构建时,我会看到以下错误:
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)的样子:
Nan::New<FunctionTemplate>(FFIPrepCif)->GetFunction());这就是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);因此,新版本的v8似乎要求向GetFunction传递上下文吗?不确定。我不是JS程序员,也不是C++程序员。我想如果是简单的事情,比如安装一些新的库?
在这一点上,https://github.com/node-ffi/node-ffi/tree/master/src是我本质上处理的代码。
你能给我指出正确的方向吗?
谢谢。
发布于 2022-03-21 09:53:54
如果节点-ffi不再维护。不适用于Node版本> 10,则使用节肢动物代替。有许多相关的包也不再维护,并且具有napi功能叉(例如,ref-napi,ref-wchar-napi)。
据我所知,旧包和napi分叉具有相同的API,因此您只需安装新版本并更改代码中的导入,它就应该安装和运行。
https://stackoverflow.com/questions/64031212
复制相似问题