When performing yarn install on wsl I get the following error:
Directory: node_modules/node-hid
Output:
prebuild-install WARN install No prebuilt binaries found (target=18.13.0 runtime=node arch=x64 libc= platform=linux)
gyp info it worked if it ends with ok
gyp info using node-gyp#9.1.0
gyp info using node#18.13.0 | linux | x64
gyp info find Python using Python version 3.8.10 found at \"/usr/bin/python3\"
gyp http GET https://nodejs.org/download/release/v18.13.0/node-v18.13.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v18.13.0/node-v18.13.0-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v18.13.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v18.13.0/SHASUMS256.txt
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args '/home/.nvm/versions/node/v18.13.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/home/node_modules/node-hid/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/.nvm/versions/node/v18.13.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/.cache/node-gyp/18.13.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/.cache/node-gyp/18.13.0',
gyp info spawn args '-Dnode_gyp_dir=/home/.nvm/versions/node/v18.13.0/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/home/.cache/node-gyp/18.13.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/home/node_modules/node-hid',
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 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/node_modules/node-hid/build'
CC(target) Release/obj.target/hidapi-linux-hidraw/hidapi/linux/hid.o
AR(target) Release/obj.target/hidapi-linux-hidraw.a
COPY Release/hidapi-linux-hidraw.a
CXX(target) Release/obj.target/HID-hidraw/src/HID.o
../src/HID.cc:71:5: error: ISO C++17 does not allow dynamic exception specifications
71 | throw(JSException);
package.json:
{
"devDependencies": {
"#nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers",
"#nomiclabs/hardhat-etherscan": "^3.1.5",
"#nomiclabs/hardhat-waffle": "^2.0.3",
"chai": "^4.3.7",
"ethereum-waffle": "^4.0.9",
"ethers": "^6.0.2",
"hardhat": "^2.12.6",
"hardhat-contract-sizer": "^2.7.0",
"hardhat-deploy": "^0.11.23",
"hardhat-gas-reporter": "^1.0.9",
"prettier": "^2.8.3",
"prettier-plugin-solidity": "^1.1.1",
"solhint": "^3.3.8",
"solidity-coverage": "^0.8.2"
},
"dependencies": {
"#chainlink/contracts": "^0.6.1",
"#chainlink/test-helpers": "^0.0.7-alpha",
"#chainlink/token": "^1.1.0",
"#openzeppelin/contracts": "^4.8.1",
"dotenv": "^16.0.3",
"hardhat-shorthand": "^1.0.0"
}
}
Related
UPDATE. Output of gcc -v as requested:
→ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
I am trying to follow the Node.js official addons example
The node-gyp configure step runs without errors.
However, the following node-gyp build step is failing:
→ node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp#5.0.2
gyp info using node#10.16.0 | darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/addon/hello.o
error: invalid value 'gnu++1y' in '-std=gnu++1y'
make: *** [Release/obj.target/addon/hello.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/dmitrizaitsev/.npm-global/lib/node_modules/node-gyp/lib/build.js:190:23)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 12.6.0
gyp ERR! command "/usr/local/bin/node" "/Users/dmitrizaitsev/.npm-global/bin/node-gyp" "build"
gyp ERR! cwd /Users/dmitrizaitsev/test/addons/official
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v5.0.2
gyp ERR! not ok
The first error message is
invalid value 'gnu++1y' in '-std=gnu++1y'
What does it mean and how can this error possibly be fixed?
I want to use the DronecodeSDK (C++) library within a Node.js application. I'm currently unable to build the node-addon that includes the DronecodeSDK headers. It's only the headers within the sub-subdirectories that node-gyp can't find.
#include <dronecode_sdk/dronecode_sdk.h> is included just fine, but #include <dronecode_sdk/plugins/action/action.h> isn't.
If I move the action.h file to dronecode_sdk/action.h then the include works just fine. It's only when it's moved inside the subdirectory of plugins that it isn't found.
My binding.gyp file:
{
"targets": [
{
"include_dirs" : [
"<!(node -e \"require('nan')\")",
"../lib/DronecodeSDK/install/include"
],
"libraries": [ "../lib/DronecodeSDK/install/lib/libdronecode_sdk.a" ],
"target_name": "DronecoreSDK",
"sources": [ "DronecoreSDKBridge.cc" ]
}
]
}
Two include statements in 'DronecodeSDKBridge.cc' :
#include <dronecode_sdk/dronecode_sdk.h>
#include <dronecode_sdk/plugins/action/action.h>
I get the following error message:
gyp info it worked if it ends with ok
gyp info using node-gyp#3.8.0
gyp info using node#10.15.0 | darwin | x64
gyp info spawn /usr/local/bin/python2
gyp info spawn args [ '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/aokholm/src/kitex/_3_GroundStation/electron-GC/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/aokholm/.node-gyp/10.15.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/aokholm/.node-gyp/10.15.0',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/aokholm/.node-gyp/10.15.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/aokholm/src/kitex/_3_GroundStation/electron-GC',
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 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/DronecoreSDK/DronecoreSDKBridge.o
../DronecoreSDKBridge.cc:10:10: fatal error: 'dronecode_sdk/plugins/action/action.h' file not found
#include <dronecode_sdk/plugins/action/action.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/DronecoreSDK/DronecoreSDKBridge.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/aokholm/src/kitex/_3_GroundStation/electron-GC
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Could it be that sub-subdirectories just doesn't work, or is the error somewhere else? I have checked that the file permissions of all the headers files are readable.
Node-gyp paths are quite mysterious.
The library path ../lib/DronecodeSDK/install/lib/libdronecode_sdk.a is correct. However the include path ../lib/DronecodeSDK/install/include was incorrect.
The reason why node-gyp could find the dronecode_sdk.h header anyway is that that it by default searches for headers in the two most top level directories of the project.
Changing the include path to lib/DronecodeSDK/install/include solved the problem.
I use node-gyp to build my c++ library for node, and copy some examples on the web.
callback.cc
#include <node.h>
#include <v8.h>
using namespace v8;
Handle<Value> Method(const v8::internal::Arguments& args){
HandleScope scope;
return scope.Close(String::New("hello,world"));
}
void init(Handle<Object> exports) {
exports->Set(String::NewSymbol("hello"),FunctionTemplate::New(Method)->GetFunction());
}
NODE_MODULE(hello, init)
binding.gyp
{
"targets": [
{
"target_name": "hello",
"sources": [ "callback.cc" ]
}
]
}
run node-gyp configure ok.
run node-gyp build fail, error:
gyp info it worked if it ends with ok
gyp info using node-gyp#3.6.0
gyp info using node#7.9.0 | darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/hello/callback.o
../callback.cc:5:15: error: calling a protected constructor of class 'v8::HandleScope'
HandleScope scope;
^
/Users/zhouweiming/.node-gyp/7.9.0/include/node/v8.h:908:13: note: declared protected here
V8_INLINE HandleScope() {}
^
../callback.cc:6:16: error: no member named 'Close' in 'v8::HandleScope'
return scope.Close(String::New("hello,world"));
~~~~~ ^
../callback.cc:6:30: error: no member named 'New' in 'v8::String'
return scope.Close(String::New("hello,world"));
~~~~~~~~^
../callback.cc:9:65: error: cannot initialize a parameter of type 'v8::Isolate *' with an lvalue of type 'Handle<v8::Value> (const v8::internal::Arguments &)'
(aka 'v8::Local<v8::Value> (const v8::internal::Arguments &)')
exports->Set(String::NewSymbol("hello"),FunctionTemplate::New(Method)->GetFunction());
^~~~~~
/Users/zhouweiming/.node-gyp/7.9.0/include/node/v8.h:5079:16: note: passing argument to parameter 'isolate' here
Isolate* isolate, FunctionCallback callback = 0,
^
../callback.cc:9:24: error: no member named 'NewSymbol' in 'v8::String'
exports->Set(String::NewSymbol("hello"),FunctionTemplate::New(Method)->GetFunction());
~~~~~~~~^
5 errors generated.
make: *** [Release/obj.target/hello/callback.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/.node-gyp_npminstall/node_modules/.node- gyp#3.6.0/lib/build.js:285:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:194:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 16.5.0
gyp ERR! command "/usr/local/Cellar/node/6.9.1/bin/node" "/usr/local/bin/node-gyp" "build"
gyp ERR! cwd /Users/zhouweiming/data/project/electron-projects/dll
gyp ERR! node -v v7.9.0
gyp ERR! node-gyp -v v3.6.0
gyp ERR! not ok
I'm not a c++ coder, please help me.
node: 7.9.0
node-gyp: 3.6.0
xcode: 8.1
mac: 10.12.4
gcc:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
I have solved it. Because the c++ code in demo is outdated.
the new codes like:
#include <node/v8.h>
#include <node/node.h>
using namespace node;
using namespace v8;
void Method(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, "Hello world"));
}
void init(v8::Local<v8::Object> target) {
NODE_SET_METHOD(target, "hello", Method);
}
NODE_MODULE(binding, init);
there are too many outdated examples on the web, I will keep this question
I'm trying to npm install -g node-xmpp and the build fails on the c++ compilation part with the following error:
LINK : fatal error LNK1181: cannot open input file 'kernel32.lib' [C:\Users\jhon\AppData\Roaming\npm\node_modules\node-xmpp\node_modules\node-expat\build\node_expat.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\12.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:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\shon\AppData\Roaming\npm\node_modules\node-xmpp\node_modules\node-expat
gyp ERR! node -v v0.10.24
gyp ERR! node-gyp -v v0.12.1
gyp ERR! not ok
I've tried removing and re-installing all my visual studio components, with no luck (currently using VS 2013 express).
if I look at the environment vars on visual studio command prompt, I can see that windowssdkdir points to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\ and kernel32.lib is there at the Lib dir.
I'm lost, any help would be appreciated
I'm trying to build a nodejs module with C++ and Ubuntu 13.04 using some boost headers as shown below:
#include <iostream>
#include <string>
#include <node/node.h>
#include <v8.h>
#include <boost/lexical_cast.hpp>
using namespace std;
using namespace v8;
Handle<Value> Method(const Arguments& args) {
HandleScope scope;
std::string foobar = "8";
return scope.Close(String::New("world"));
}
void init(Handle<Object> exports){
exports->Set(String::NewSymbol("Hello"),
FunctionTemplate::New(Method)->GetFunction());
}
NODE_MODULE(hello, init)
However, when compiling with node-gyp, I get the following errors:
sam#ubuntu:~/workspace_cpp/NodeTest/src$ node-gyp build gyp info it
worked if it ends with ok gyp info using node-gyp#0.10.9 gyp info
using node#0.10.15 | linux | x64 gyp info spawn make gyp info spawn
args [ 'BUILDTYPE=Release', '-C', 'build' ] make: Entering directory
/home/sam/workspace_cpp/NodeTest/src/build' CXX(target)
Release/obj.target/hello/NodeTest.o In file included from
/usr/include/boost/numeric/conversion/converter.hpp:14:0,
from /usr/include/boost/numeric/conversion/cast.hpp:33,
from /usr/include/boost/lexical_cast.hpp:66,
from ../NodeTest.cpp:13: /usr/include/boost/numeric/conversion/converter_policies.hpp: In
member function ‘void
boost::numeric::def_overflow_handler::operator()(boost::numeric::range_check_result)’:
/usr/include/boost/numeric/conversion/converter_policies.hpp:162:31:
error: exception handling disabled, use -fexceptions to enable make:
*** [Release/obj.target/hello/NodeTest.o] Error 1 make: Leaving directory/home/sam/workspace_cpp/NodeTest/src/build' gyp ERR! build
error gyp ERR! stack Error: make failed with exit code: 2 gyp ERR!
stack at ChildProcess.onExit
(/usr/local/lib/node_modules/node-gyp/lib/build.js:267:23) gyp ERR!
stack at ChildProcess.EventEmitter.emit (events.js:98:17) gyp ERR!
stack at Process.ChildProcess._handle.onexit
(child_process.js:789:12) gyp ERR! System Linux 3.8.0-19-generic gyp
ERR! command "node" "/usr/local/bin/node-gyp" "build" gyp ERR! cwd
/home/sam/workspace_cpp/NodeTest/src gyp ERR! node -v v0.10.15 gyp
ERR! node-gyp -v v0.10.9 gyp ERR! not ok
I cannot find anything on the web for how to get node-gyp to build with other libraries such as boost. Does anybody have any insight or experience with this? My ultimate goal is to make a SOAP module using gsoap.
EDIT
I'm assuming that I have to edit my binding.gyp file in some way to allow for boost to be compiled. As it sits, this file currently looks like this:
{ "targets": [
{
"target_name": "hello",
"sources": [ "NodeTest.cpp" ]
} ] }
For anybody else that has this error, the key is enabling exceptions for node-gyp. In your bindings.gyp file, make sure you include this
...
'cflags!': [ '-fno-exceptions' ],
'cflags_cc!': [ '-fno-exceptions' ]
...
I found my solution in this forum post: GitHub