I am new to nodejs. I am trying to call c++ API in a dll from node-js. So far I found that ffi can be used to do it. I followed the install instructions and installed the necessary build tools. But when I run npm install ffi
I get the following errors.
Am I doing something wrong?
**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! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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
If your npm is broken: On Mac or Linux, reinstall npm. Windows: If you're on Windows and you have a broken installation, the easiest thing to do is to reinstall node from the official installer (see this note about installing the latest stable version).
code 1 error usually occurs when you run the npm install command. This cause of this error is that one of the dependencies you define in your package. json file fails to be installed properly on your computer. This means that npm fails to install the node-sass module that's added as a dependency to the n-app project.
node-ffi is a Node. js addon for loading and calling dynamic libraries using pure JavaScript. It can be used to create bindings to native libraries without writing any C++ code. It also simplifies the augmentation of node.
Install node using the windows installer. Make sure the files were extracted to C:\Program Files (x86)\nodejs\ Make sure that my Path enviorment variable contains C:\Program Files (x86)\nodejs\ open up a command prompt and run node -v.
Please uninstall node. js and use the Node v14. x. It will solve it automatically.
It is because node-ffi does not support node 12 Here's one of the issues open on their github: https://github.com/node-ffi/node-ffi/issues/545
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With