Задать вопрос
@mgkirs

Как установить tinycbor | npm i tinycbor, у всех так c ошибкой не собираеются addon на Node.js error: cannot convert 'v8::MaybeLocal' to 'v8::Local'?

Не собирается ни nan, ни tinycbor

нехватает локалей, пакетов, i18, чего еще?
Может я не знаю как конфигурировать binding.gyp?
результат на alpine и debian ничем не отличается
это различия между апи адонами nodejs разных версий?
не праильно или вообще не работет node-gyp?

error: cannot convert 'v8::MaybeLocal' to 'v8::Local'

(base) [angular]$ docker-compose run vite npm i --save-dev tinycbor@0.2.1
WARN idealTree Removing dependencies.tinycbor in favor of devDependencies.tinycbor
ERR! code 1
ERR! path /code/angular/node_modules/tinycbor
ERR! command failed
ERR! command sh -c node-gyp rebuild
ERR! make: Entering directory '/code/angular/node_modules/tinycbor/build'
ERR! CXX(target) Release/obj.target/CBOR/src/addon_main.o
ERR! make: Leaving directory '/code/angular/node_modules/tinycbor/build'
ERR! gyp info it worked if it ends with ok
ERR! gyp info using node-gyp@9.3.1
ERR! gyp info using node@18.15.0 | linux | x64
ERR! gyp info find Python using Python version 3.11.2 found at "/usr/bin/python3"
ERR! gyp http GET https://unofficial-builds.nodejs.org/download/rele...
ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/rele...
ERR! gyp http GET https://unofficial-builds.nodejs.org/download/rele...
ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/rele...
ERR! gyp info spawn /usr/bin/python3
ERR! gyp info spawn args [
ERR! gyp info spawn args '/code/angular/node_modules/node-gyp/gyp/gyp_main.py',
ERR! gyp info spawn args 'binding.gyp',
ERR! gyp info spawn args '-f',
ERR! gyp info spawn args 'make',
ERR! gyp info spawn args '-I',
ERR! gyp info spawn args '/code/angular/node_modules/tinycbor/build/config.gypi',
ERR! gyp info spawn args '-I',
ERR! gyp info spawn args '/code/angular/node_modules/node-gyp/addon.gypi',
ERR! gyp info spawn args '-I',
ERR! gyp info spawn args '/root/.cache/node-gyp/18.15.0/include/node/common.gypi',
ERR! gyp info spawn args '-Dlibrary=shared_library',
ERR! gyp info spawn args '-Dvisibility=default',
ERR! gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/18.15.0',
ERR! gyp info spawn args '-Dnode_gyp_dir=/code/angular/node_modules/node-gyp',
ERR! gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/18.15.0/<(target_arch)/node.lib',
ERR! gyp info spawn args '-Dmodule_root_dir=/code/angular/node_modules/tinycbor',
ERR! gyp info spawn args '-Dnode_engine=v8',
ERR! gyp info spawn args '--depth=.',
ERR! gyp info spawn args '--no-parallel',
ERR! gyp info spawn args '--generator-output',
ERR! gyp info spawn args 'build',
ERR! gyp info spawn args '-Goutput_dir=.'
ERR! gyp info spawn args ]
ERR! gyp info spawn make
ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
ERR! ../src/addon_main.cc: In function 'void addon::Encode(const v8::FunctionCallbackInfo&)':
ERR! ../src/addon_main.cc:49:26: error: cannot convert 'v8::MaybeLocal' to 'v8::Local'
ERR! 49 | String::NewFromUtf8(isolate, "This method requires one argument")));
ERR! | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERR! | v8::MaybeLocal
ERR! In file included from /root/.cache/node-gyp/18.15.0/include/node/v8.h:30,
ERR! from /root/.cache/node-gyp/18.15.0/include/node/node.h:73,
ERR! from ../src/addon_encoding.h:7,
ERR! from ../src/addon_main.cc:11:
ERR! /root/.cache/node-gyp/18.15.0/include/node/v8-exception.h:36:47: note: initializing argument 1 of 'static v8::Local v8::Exception::TypeError(v8::Local)'
ERR! 36 | static Local TypeError(Local message);
ERR! | ~~~~~~~~~~~~~~^~~~~~~
ERR! ../src/addon_main.cc:61:45: error: no matching function for call to 'v8::ArrayBuffer::New(v8::Isolate*&, uint8_t*&, size_t&, v8::ArrayBufferCreationMode)'
ERR! 61 | args.GetReturnValue().Set(ArrayBuffer::New(isolate, serialized, size, ArrayBufferCreationMode::kExternalized));
ERR! | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERR! In file included from /root/.cache/node-gyp/18.15.0/include/node/v8.h:24:
ERR! /root/.cache/node-gyp/18.15.0/include/node/v8-array-buffer.h:198:29: note: candidate: 'static v8::Local v8::ArrayBuffer::New(v8::Isolate*, size_t)'
ERR! 198 | static Local New(Isolate* isolate, size_t byte_length);
ERR! | ^~~
ERR! /root/.cache/node-gyp/18.15.0/include/node/v8-array-buffer.h:198:29: note: candidate expects 2 arguments, 4 provided
ERR! /root/.cache/node-gyp/18.15.0/include/node/v8-array-buffer.h:212:29: note: candidate: 'static v8::Local v8::ArrayBuffer::New(v8::Isolate*, std::shared_ptr)'
ERR! 212 | static Local New(Isolate* isolate,
ERR! | ^~~
ERR! /root/.cache/node-gyp/18.15.0/include/node/v8-array-buffer.h:212:29: note: candidate expects 2 arguments, 4 provided
ERR! ../src/addon_main.cc: In function 'void addon::Decode(const v8::FunctionCallbackInfo&)':
ERR! ../src/addon_main.cc:77:26: error: cannot convert 'v8::MaybeLocal' to 'v8::Local'
ERR! 77 | String::NewFromUtf8(isolate, "This method requires one argument")));
ERR! | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERR! | v8::MaybeLocal
ERR! /root/.cache/node-gyp/18.15.0/include/node/v8-exception.h:36:47: note: initializing argument 1 of 'static v8::Local v8::Exception::TypeError(v8::Local)'
ERR! 36 | static Local TypeError(Local message);
ERR! | ~~~~~~~~~~~~~~^~~~~~~
ERR! ../src/addon_main.cc:87:36: error: 'class v8::ArrayBuffer' has no member named 'GetContents'
ERR! 87 | uint8_t* buffer = (uint8_t*) ab->GetContents().Data();
ERR! | ^~~~~~~~~~~
ERR! ../src/addon_main.cc: In function 'void addon::Text(const v8::FunctionCallbackInfo&)':
ERR! ../src/addon_main.cc:109:26: error: cannot convert 'v8::MaybeLocal' to 'v8::Local'
ERR! 109 | String::NewFromUtf8(isolate, "This method requires one argument")));
ERR! | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERR! | v8::MaybeLocal
ERR! /root/.cache/node-gyp/18.15.0/include/node/v8-exception.h:36:47: note: initializing argument 1 of 'static v8::Local v8::Exception::TypeError(v8::Local)'
ERR! 36 | static Local TypeError(Local message);
ERR! | ~~~~~~~~~~~~~~^~~~~~~
ERR! ../src/addon_main.cc:118:36: error: 'class v8::ArrayBuffer' has no member named 'GetContents'
ERR! 118 | uint8_t* buffer = (uint8_t*) ab->GetContents().Data();
ERR! | ^~~~~~~~~~~
ERR! ../src/addon_main.cc: In function 'void addon::JSON(const v8::FunctionCallbackInfo&)':
ERR! ../src/addon_main.cc:147:26: error: cannot convert 'v8::MaybeLocal' to 'v8::Local'
ERR! 147 | String::NewFromUtf8(isolate, "This method requires one argument")));
ERR! | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERR! | v8::MaybeLocal
ERR! /root/.cache/node-gyp/18.15.0/include/node/v8-exception.h:36:47: note: initializing argument 1 of 'static v8::Local v8::Exception::TypeError(v8::Local)'
ERR! 36 | static Local TypeError(Local message);
ERR! | ~~~~~~~~~~~~~~^~~~~~~
ERR! ../src/addon_main.cc:156:36: error: 'class v8::ArrayBuffer' has no member named 'GetContents'
ERR! 156 | uint8_t* buffer = (uint8_t*) ab->GetContents().Data();
ERR! | ^~~~~~~~~~~
ERR! ../src/addon_main.cc: At global scope:
ERR! /root/.cache/node-gyp/18.15.0/include/node/node.h:978:7: warning: cast between incompatible function types from 'void (*)(v8::Local)' to 'node::addon_register_func' {aka 'void (*)(v8::Local, v8::Local, void*)'} [-Wcast-function-type]
ERR! 978 | (node::addon_register_func) (regfunc), \
ERR! | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERR! /root/.cache/node-gyp/18.15.0/include/node/node.h:1012:3: note: in expansion of macro 'NODE_MODULE_X'
ERR! 1012 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
ERR! | ^~~~~~~~~~~~~
ERR! ../src/addon_main.cc:181:1: note: in expansion of macro 'NODE_MODULE'
ERR! 181 | NODE_MODULE(addon, init)
ERR! | ^~~~~~~~~~~
ERR! make: *** [CBOR.target.mk:148: Release/obj.target/CBOR/src/addon_main.o] Error 1
ERR! gyp ERR! build error
ERR! gyp ERR! stack Error: `make` failed with exit code: 2
ERR! gyp ERR! stack at ChildProcess.onExit (/code/angular/node_modules/node-gyp/lib/build.js:203:23)
ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12)
ERR! gyp ERR! System Linux 5.15.90.1-microsoft-standard-WSL2
ERR! gyp ERR! command "/usr/local/bin/node" "/code/angular/node_modules/.bin/node-gyp" "rebuild"
ERR! gyp ERR! cwd /code/angular/node_modules/tinycbor
ERR! gyp ERR! node -v v18.15.0
ERR! gyp ERR! node-gyp -v v9.3.1
ERR! gyp ERR! not ok

ERR! A complete log of this run can be found in:
ERR! /root/.npm/_logs/2023-03-28T11_17_56_176Z-debug-0.log
(base) [angular]$
  • Вопрос задан
  • 82 просмотра
Подписаться 1 Средний Комментировать
Пригласить эксперта
Ответы на вопрос 1
bingo347
@bingo347 Куратор тега Node.js
Crazy on performance...
Данный пакет использует "классическое" C++ api для аддонов вместо napi, которое как правило меняется с каждой мажорной версией node.js.
Так как данный пакет последний раз опубликован 6 лет назад, то вряд ли его когда-то обновят под 18 версию.
Я бы поискал другой пакет для CBOR, благо их не мало написанных на самом JS, а не в виде аддонов.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы