为什么npm install ffi返回错误。使用节点版本12

时间:2019-05-31 10:39:22

标签: c++ node.js node-ffi

我是nodejs的新手。我正在尝试从node-js的dll中调用c ++ API。到目前为止,我发现可以使用ffi。我按照安装说明进行操作,并安装了必要的构建工具。但是当我运行npm install ffi时,出现以下错误。

我做错什么了吗?

**d:\codelathe\electronpoc\practice\dll\electroncallingdll\node_modules\ref\src\binding.cc(222): error C2661: 'v8::Value:
:BooleanValue': no overloaded function takes 0 arguments**
 [D:\CodeLathe\ElectronPOC\Practice\dll\ElectroncallingDll\node
_modules\ref\build\binding.vcxproj]
d:\codelathe\electronpoc\practice\dll\electroncallingdll\node_modules\ref\src\binding.cc(253): error C2660: 'v8::Value:
:Uint32Value': function does not take 0 arguments [D:\CodeLathe\ElectronPOC\Practice\dll\ElectroncallingDll\node_module
s\ref\build\binding.vcxproj]
  c:\users\nikhe\.node-gyp\12.0.0\include\node\v8.h(2567): note: see declaration of 'v8::Value::Uint32Value' (compiling
   source file ..\src\binding.cc)
d:\codelathe\electronpoc\practice\dll\electroncallingdll\node_modules\ref\src\binding.cc(360): error C2664: 'v8::String
::Utf8Value::Utf8Value(const v8::String::Utf8Value &)': cannot convert argument 1 from 'v8::Local<v8::Value>' to 'const
 v8::String::Utf8Value &' [D:\CodeLathe\ElectronPOC\Practice\dll\ElectroncallingDll\node_modules\ref\build\binding.vcxp
roj]
  d:\codelathe\electronpoc\practice\dll\electroncallingdll\node_modules\ref\src\binding.cc(360): note: Reason: cannot c
  onvert from 'v8::Local<v8::Value>' to 'const v8::String::Utf8Value'
  d:\codelathe\electronpoc\practice\dll\electroncallingdll\node_modules\ref\src\binding.cc(360): note: No user-defined-
  conversion operator available that can perform this conversion, or the operator cannot be called
d:\codelathe\electronpoc\practice\dll\electroncallingdll\node_modules\ref\src\binding.cc(447): error C2664: 'v8::String
::Utf8Value::Utf8Value(const v8::String::Utf8Value &)': cannot convert argument 1 from 'v8::Local<v8::Value>' to 'const
 v8::String::Utf8Value &' [D:\CodeLathe\ElectronPOC\Practice\dll\ElectroncallingDll\node_modules\ref\build\binding.vcxp
roj]
  d:\codelathe\electronpoc\practice\dll\electroncallingdll\node_modules\ref\src\binding.cc(447): note: Reason: cannot c
  onvert from 'v8::Local<v8::Value>' to 'const v8::String::Utf8Value'
  d:\codelathe\electronpoc\practice\dll\electroncallingdll\node_modules\ref\src\binding.cc(447): note: No user-defined-
  conversion operator available that can perform this conversion, or the operator cannot be called
d:\codelathe\electronpoc\practice\dll\electroncallingdll\node_modules\ref\src\binding.cc(521): error C2660: 'v8::Value:
:Uint32Value': function does not take 0 arguments [D:\CodeLathe\ElectronPOC\Practice\dll\ElectroncallingDll\node_module
s\ref\build\binding.vcxproj]
  c:\users\nikhe\.node-gyp\12.0.0\include\node\v8.h(2567): note: see declaration of 'v8::Value::Uint32Value' (compiling
   source file ..\src\binding.cc)
d:\codelathe\electronpoc\practice\dll\electroncallingdll\node_modules\ref\src\binding.cc(550): error C2660: 'v8::Value:
:Uint32Value': function does not take 0 arguments [D:\CodeLathe\ElectronPOC\Practice\dll\ElectroncallingDll\node_module
s\ref\build\binding.vcxproj]
.
.
.
. d:\codelathe\electronpoc\practice\dll\electroncallingdll\node_modules\nan\nan_maybe_43_inl.h(117): note: see declarat
  ion of 'Nan::ForceSet'
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:196:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:256:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\CodeLathe\ElectronPOC\Practice\dll\ElectroncallingDll\node_modules\ref
gyp ERR! node -v v12.0.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open 'D:\CodeLathe\ElectronPOC\Practice\dll\ElectroncallingDll\package.json'
npm WARN ElectroncallingDll No description
npm WARN ElectroncallingDll No repository field.
npm WARN ElectroncallingDll No README data
npm WARN ElectroncallingDll No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ref@1.3.5 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ref@1.3.5 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\nikhe\AppData\Roaming\npm-cache\_logs\2019-05-31T10_07_30_614Z-debug.log

2 个答案:

答案 0 :(得分:1)

这是因为node-ffi不支持节点12 这是在github上打开的问题之一:https://github.com/node-ffi/node-ffi/issues/545

答案 1 :(得分:0)

对于 Windows 用户!

如果您没有安装 node-gyp,请访问此链接 https://github.com/nodejs/node-gyp#on-windows

降级 Node 版本对我有用。为了降级 Node 版本,请使用 NVM For windows