Node v12 support?

#5 · open · 5 comments

View on GitHub ↗

mildmojo

Hi! This project's `nan` dependency was updated to the latest 2.13.2, but it fails to build under Node v12 (I used v12.2.0). It looks like some APIs may have changed? Nan has a v12 tracking ticket at nodejs/nan#849. I've been using [child_pty](/Gottox/child_pty) but wasn't able to update it for Node v12 because of the build errors in this package. I looked around a bit for a `nan` version migration guide to help, but didn't find one. =/ I was able to install `child_pty` (and therefore this package) successfully under Node v10. ``` $ npm install node-termios > [email protected] install /Users/me/code/xometry/node_modules/termios > node-gyp rebuild CXX(target) Release/obj.target/termios/src/termios.o ../src/termios.cpp:72:39: error: no matching member function for call to 'ToObject' v8::Local<v8::Object> obj = info[2]->ToObject(); ~~~~~~~~~^~~~~~~~ /Users/me/.node-gyp/12.2.0/include/node/v8.h:2532:44: note: candidate function not viable: requires single argument 'context', but no arguments were provided V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject( ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:2546:35: note: candidate function not viable: requires single argument 'isolate', but no arguments were provided Local<Object> ToObject(Isolate* isolate) const); ^ ../src/termios.cpp:82:37: error: too few arguments to function call, single argument 'context' was not specified if (tcgetattr(info[0]->Uint32Value(), &t) < 0) { ~~~~~~~~~~~~~~~~~~~~ ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:2567:3: note: 'Uint32Value' declared here V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value( ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:347:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT' #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) ^ ../src/termios.cpp:85:11: error: no matching member function for call to 'Has' if (obj->Has(iflag)) { ~~~~~^~~ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3449:37: note: candidate function not viable: requires 2 arguments, but 1 was provided V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3455:37: note: candidate function not viable: requires 2 arguments, but 1 was provided V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, uint32_t index); ^ ../src/termios.cpp:86:20: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations] t.c_iflag = obj->Get(iflag)->Uint32Value(); ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3412:3: note: 'Get' has been explicitly marked deprecated here V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Local<Value> key)); ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:322:29: note: expanded from macro 'V8_DEPRECATE_SOON' declarator __attribute__((deprecated(message))) ^ ../src/termios.cpp:86:44: error: too few arguments to function call, single argument 'context' was not specified t.c_iflag = obj->Get(iflag)->Uint32Value(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:2567:3: note: 'Uint32Value' declared here V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value( ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:347:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT' #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) ^ ../src/termios.cpp:88:11: error: no matching member function for call to 'Has' if (obj->Has(oflag)) { ~~~~~^~~ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3449:37: note: candidate function not viable: requires 2 arguments, but 1 was provided V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3455:37: note: candidate function not viable: requires 2 arguments, but 1 was provided V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, uint32_t index); ^ ../src/termios.cpp:89:20: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations] t.c_oflag = obj->Get(oflag)->Uint32Value(); ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3412:3: note: 'Get' has been explicitly marked deprecated here V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Local<Value> key)); ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:322:29: note: expanded from macro 'V8_DEPRECATE_SOON' declarator __attribute__((deprecated(message))) ^ ../src/termios.cpp:89:44: error: too few arguments to function call, single argument 'context' was not specified t.c_oflag = obj->Get(oflag)->Uint32Value(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:2567:3: note: 'Uint32Value' declared here V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value( ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:347:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT' #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) ^ ../src/termios.cpp:91:11: error: no matching member function for call to 'Has' if (obj->Has(cflag)) { ~~~~~^~~ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3449:37: note: candidate function not viable: requires 2 arguments, but 1 was provided V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3455:37: note: candidate function not viable: requires 2 arguments, but 1 was provided V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, uint32_t index); ^ ../src/termios.cpp:92:20: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations] t.c_cflag = obj->Get(cflag)->Uint32Value(); ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3412:3: note: 'Get' has been explicitly marked deprecated here V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Local<Value> key)); ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:322:29: note: expanded from macro 'V8_DEPRECATE_SOON' declarator __attribute__((deprecated(message))) ^ ../src/termios.cpp:92:44: error: too few arguments to function call, single argument 'context' was not specified t.c_cflag = obj->Get(cflag)->Uint32Value(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:2567:3: note: 'Uint32Value' declared here V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value( ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:347:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT' #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) ^ ../src/termios.cpp:94:11: error: no matching member function for call to 'Has' if (obj->Has(cbaud)) { ~~~~~^~~ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3449:37: note: candidate function not viable: requires 2 arguments, but 1 was provided V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3455:37: note: candidate function not viable: requires 2 arguments, but 1 was provided V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, uint32_t index); ^ ../src/termios.cpp:95:56: error: too few arguments to function call, single argument 'context' was not specified int mask = baud_to_mask(obj->Get(cbaud)->Uint32Value()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:2567:3: note: 'Uint32Value' declared here V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value( ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:347:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT' #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) ^ ../src/termios.cpp:95:32: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations] int mask = baud_to_mask(obj->Get(cbaud)->Uint32Value()); ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3412:3: note: 'Get' has been explicitly marked deprecated here V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Local<Value> key)); ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:322:29: note: expanded from macro 'V8_DEPRECATE_SOON' declarator __attribute__((deprecated(message))) ^ ../src/termios.cpp:103:11: error: no matching member function for call to 'Has' if (obj->Has(lflag)) { ~~~~~^~~ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3449:37: note: candidate function not viable: requires 2 arguments, but 1 was provided V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3455:37: note: candidate function not viable: requires 2 arguments, but 1 was provided V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, uint32_t index); ^ ../src/termios.cpp:104:20: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations] t.c_lflag = obj->Get(lflag)->Uint32Value(); ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3412:3: note: 'Get' has been explicitly marked deprecated here V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Local<Value> key)); ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:322:29: note: expanded from macro 'V8_DEPRECATE_SOON' declarator __attribute__((deprecated(message))) ^ ../src/termios.cpp:104:44: error: too few arguments to function call, single argument 'context' was not specified t.c_lflag = obj->Get(lflag)->Uint32Value(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:2567:3: note: 'Uint32Value' declared here V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value( ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:347:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT' #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) ^ ../src/termios.cpp:106:37: error: too few arguments to function call, single argument 'context' was not specified if (tcsetattr(info[0]->Uint32Value(), TCSADRAIN, &t) < 0) { ~~~~~~~~~~~~~~~~~~~~ ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:2567:3: note: 'Uint32Value' declared here V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value( ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:347:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT' #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) ^ ../src/termios.cpp:114:37: error: too few arguments to function call, single argument 'context' was not specified if (tcgetattr(info[0]->Uint32Value(), &t) < 0) { ~~~~~~~~~~~~~~~~~~~~ ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:2567:3: note: 'Uint32Value' declared here V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value( ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:347:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT' #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) ^ ../src/termios.cpp:118:7: warning: 'Set' is deprecated: Use maybe version [-Wdeprecated-declarations] obj->Set(Nan::New<v8::String>("iflag").ToLocalChecked(), Nan::New<v8::Number>(t.c_iflag)); ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3358:3: note: 'Set' has been explicitly marked deprecated here V8_DEPRECATE_SOON("Use maybe version", ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:322:29: note: expanded from macro 'V8_DEPRECATE_SOON' declarator __attribute__((deprecated(message))) ^ ../src/termios.cpp:119:7: warning: 'Set' is deprecated: Use maybe version [-Wdeprecated-declarations] obj->Set(Nan::New<v8::String>("oflag").ToLocalChecked(), Nan::New<v8::Number>(t.c_oflag)); ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3358:3: note: 'Set' has been explicitly marked deprecated here V8_DEPRECATE_SOON("Use maybe version", ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:322:29: note: expanded from macro 'V8_DEPRECATE_SOON' declarator __attribute__((deprecated(message))) ^ ../src/termios.cpp:120:7: warning: 'Set' is deprecated: Use maybe version [-Wdeprecated-declarations] obj->Set(Nan::New<v8::String>("cflag").ToLocalChecked(), Nan::New<v8::Number>(t.c_cflag)); ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3358:3: note: 'Set' has been explicitly marked deprecated here V8_DEPRECATE_SOON("Use maybe version", ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:322:29: note: expanded from macro 'V8_DEPRECATE_SOON' declarator __attribute__((deprecated(message))) ^ ../src/termios.cpp:123:8: warning: 'Set' is deprecated: Use maybe version [-Wdeprecated-declarations] obj->Set(Nan::New<v8::String>("cbaud").ToLocalChecked(), Nan::New<v8::Number>(baud)); ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3358:3: note: 'Set' has been explicitly marked deprecated here V8_DEPRECATE_SOON("Use maybe version", ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:322:29: note: expanded from macro 'V8_DEPRECATE_SOON' declarator __attribute__((deprecated(message))) ^ ../src/termios.cpp:125:7: warning: 'Set' is deprecated: Use maybe version [-Wdeprecated-declarations] obj->Set(Nan::New<v8::String>("lflag").ToLocalChecked(), Nan::New<v8::Number>(t.c_lflag)); ^ /Users/me/.node-gyp/12.2.0/include/node/v8.h:3358:3: note: 'Set' has been explicitly marked deprecated here V8_DEPRECATE_SOON("Use maybe version", ^ /Users/me/.node-gyp/12.2.0/include/node/v8config.h:322:29: note: expanded from macro 'V8_DEPRECATE_SOON' declarator __attribute__((deprecated(message))) ^ ../src/termios.cpp:130:6: error: variable has incomplete type 'void' void Init(v8::Handle<v8::Object> exports) { ^ ../src/termios.cpp:130:15: error: no member named 'Handle' in namespace 'v8' void Init(v8::Handle<v8::Object> exports) { ~~~~^ ../src/termios.cpp:130:32: error: expected '(' for function-style cast or type construction void Init(v8::Handle<v8::Object> exports) { ~~~~~~~~~~^ ../src/termios.cpp:130:34: error: use of undeclared identifier 'exports' void Init(v8::Handle<v8::Object> exports) { ^ ../src/termios.cpp:130:42: error: expected ';' after top level declarator void Init(v8::Handle<v8::Object> exports) { ^ ; 10 warnings and 19 errors generated. make: *** [Release/obj.target/termios/src/termios.o] Error 1 gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/Users/me/.nvm/versions/node/v12.2.0/lib/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:257:12) gyp ERR! System Darwin 16.7.0 gyp ERR! command "/Users/me/.nvm/versions/node/v12.2.0/bin/node" "/Users/me/.nvm/versions/node/v12.2.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /Users/me/code/xometry/tmp/node-termios gyp ERR! node -v v12.2.0 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok npm WARN enoent ENOENT: no such file or directory, open '/Users/me/code/xometry/package.json' npm WARN xometry No description npm WARN xometry No repository field. npm WARN xometry No README data npm WARN xometry 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! /Users/me/.npm/_logs/2019-05-09T21_26_03_581Z-debug.log ```

Comments

TKasperczyk

**ToObject** calls could be converted to: ` v8::Local<v8::Object> obj = Nan::To<v8::Object>(val).ToLocalChecked();` ("val" should be replaced). The only problem is that `v8::Local::Has` won't work and I didn't find a workaround (I've never done anything in v8). **Uint32Value** calls could be converted to: `UInt32Value(Nan::GetCurrentContext()).ToChecked();`

unphased

Thanks for the notes @TKasperczyk, do you happen to have a working branch we could temporarily point to? Alternatively, @mildmojo is it possible (at least for now) to fork and revert the `2.13.2` change and retain the ability to build/install with node v12?

TKasperczyk

@unphased Unfortunately, for now, I don't. I will get back to it in the future and post a working fork here in the comments.

TKasperczyk

@unphased Better late than never, eh? I **really** needed this module for my private project and as they say, nothing motivates more than necessity. I've just created the pull request #6

unphased

Oh, nice. I have been resorting to other less low level methods for node based CLI tooling but this is good news, thank you. I wish I left myself breadcrumbs for what the package even was that I was using which depended on this package 🤣