- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 Node.js v12.13.0 堆栈中运行以下帖子,但无法呈现它 https://medium.com/@tarkus/how-to-call-c-c-code-from-node-js-86a773033892
[ec2-user@sandbox cpptest]$ sudo npm install
npm WARN lifecycle cpptest@1.0.0~install: cannot run in wd cpptest@1.0.0 node-gyp rebuild (wd=/home/ec2-user/cpptest)
npm WARN cpptest@1.0.0 No description
npm WARN cpptest@1.0.0 No repository field.
audited 1 package in 0.577s
found 0 vulnerabilities
[ec2-user@sandbox cpptest]$ node --napi-modules -e \
> "console.log(require('./build/Release/native.node').hello())"
internal/modules/cjs/loader.js:797
throw err;
^
Error: Cannot find module './build/Release/native.node'
Require stack:
- /home/ec2-user/cpptest/[eval]
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at [eval]:1:13
at Script.runInThisContext (vm.js:116:20)
at Object.runInThisContext (vm.js:306:38)
at Object.<anonymous> ([eval]-wrapper:9:26)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at evalScript (internal/process/execution.js:80:25) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/ec2-user/cpptest/[eval]' ]
}
如果我以普通用户身份运行,这就是我得到的
[ec2-user@sandbox cpptest]$ npm install
> cpptest@1.0.0 install /home/ec2-user/cpptest
> node-gyp rebuild
make: Entering directory `/home/ec2-user/cpptest/build'
SOLINK_MODULE(target) Release/obj.target/node_modules/node-addon-api/src/nothing.node
COPY Release/nothing.node
CXX(target) Release/obj.target/native/binding.o
In file included from /home/ec2-user/cpptest/node_modules/node-addon-api/napi.h:1449:0,
from ../binding.cpp:1:
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h: In member function ‘Napi::Value Napi::Function::MakeCallback(napi_value, size_t, napi_value__* const*) const’:
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h:1277:44: error: cannot convert ‘napi_value’ to ‘napi_async_context’ for argument ‘2’ to ‘napi_status napi_make_callback(napi_env, napi_async_context, napi_value, napi_value, size_t, napi_value__* const*, napi_value__**)’
_env, recv, _value, argc, args, &result);
^
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h: In static member function ‘static void Napi::Error::Fatal(const char*, const char*)’:
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h:1484:37: error: invalid conversion from ‘const char*’ to ‘size_t {aka long unsigned int}’ [-fpermissive]
napi_fatal_error(location, message);
^
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h:1484:37: error: too few arguments to function ‘void napi_fatal_error(const char*, size_t, const char*, size_t)’
In file included from /home/ec2-user/cpptest/node_modules/node-addon-api/napi.h:4:0,
from ../binding.cpp:1:
/home/ec2-user/.cache/node-gyp/12.13.0/include/node/node_api.h:98:33: note: declared here
NAPI_EXTERN NAPI_NO_RETURN void napi_fatal_error(const char* location,
^
In file included from /home/ec2-user/cpptest/node_modules/node-addon-api/napi.h:1449:0,
from ../binding.cpp:1:
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h: In member function ‘bool Napi::CallbackInfo::IsConstructCall() const’:
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h:2020:76: error: ‘napi_is_construct_call’ was not declared in this scope
napi_status status = napi_is_construct_call(_env, _info, &isConstructCall);
^
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h: In static member function ‘static napi_value__* Napi::ObjectWrap<T>::ConstructorCallbackWrapper(napi_env, napi_callback_info)’:
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h:2474:74: error: there are no arguments to ‘napi_is_construct_call’ that depend on a template parameter, so a declaration of ‘napi_is_construct_call’ must be available [-fpermissive]
napi_status status = napi_is_construct_call(env, info, &isConstructCall);
^
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h:2474:74: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h: In constructor ‘Napi::AsyncWorker::AsyncWorker(const Napi::Object&, const Napi::Function&)’:
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h:2684:50: error: cannot convert ‘void (*)(napi_env, void*) {aka void (*)(napi_env__*, void*)}’ to ‘napi_value’ for argument ‘2’ to ‘napi_status napi_create_async_work(napi_env, napi_value, napi_value, napi_async_execute_callback, napi_async_complete_callback, void*, napi_async_work__**)’
_env, OnExecute, OnWorkComplete, this, &_work);
^
In file included from /home/ec2-user/cpptest/node_modules/node-addon-api/napi.h:4:0,
from ../binding.cpp:1:
../binding.cpp: At global scope:
/home/ec2-user/.cache/node-gyp/12.13.0/include/node/node_api.h:66:5: error: invalid conversion from ‘void (*)(napi_env, napi_value, napi_value, void*) {aka void (*)(napi_env__*, napi_value__*, napi_value__*, void*)}’ to ‘napi_addon_register_func {aka napi_value__* (*)(napi_env__*, napi_value__*)}’ [-fpermissive]
}; \
^
/home/ec2-user/.cache/node-gyp/12.13.0/include/node/node_api.h:73:3: note: in expansion of macro ‘NAPI_MODULE_X’
NAPI_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
^
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h:164:3: note: in expansion of macro ‘NAPI_MODULE’
NAPI_MODULE(modname, __napi_ ## regfunc);
^
../binding.cpp:9:1: note: in expansion of macro ‘NODE_API_MODULE’
NODE_API_MODULE(addon, Init)
^
In file included from /home/ec2-user/cpptest/node_modules/node-addon-api/napi.h:1449:0,
from ../binding.cpp:1:
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h: In instantiation of ‘static Napi::Function Napi::Function::New(napi_env, Callable, const char*, void*) [with Callable = Napi::String (*)(const Napi::CallbackInfo&); napi_env = napi_env__*]’:
../binding.cpp:7:48: required from here
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h:1212:57: error: invalid conversion from ‘napi_value__* (*)(napi_env, napi_callback_info) {aka napi_value__* (*)(napi_env__*, napi_callback_info__*)}’ to ‘size_t {aka long unsigned int}’ [-fpermissive]
env, utf8name, CbData::Wrapper, callbackData, &value);
^
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h:1212:57: error: cannot convert ‘Napi::details::CallbackData<Napi::String (*)(const Napi::CallbackInfo&), Napi::String>*’ to ‘napi_callback {aka napi_value__* (*)(napi_env__*, napi_callback_info__*)}’ for argument ‘4’ to ‘napi_status napi_create_function(napi_env, const char*, size_t, napi_callback, void*, napi_value__**)’
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h: In static member function ‘static void Napi::Error::Fatal(const char*, const char*)’:
/home/ec2-user/cpptest/node_modules/node-addon-api/napi-inl.h:1485:1: warning: ‘noreturn’ function does return [enabled by default]
}
^
make: *** [Release/obj.target/native/binding.o] Error 1
make: Leaving directory `/home/ec2-user/cpptest/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 3.10.0-514.26.2.el7.x86_64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ec2-user/cpptest
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cpptest@1.0.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cpptest@1.0.0 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! /home/ec2-user/.npm/_logs/2019-11-13T08_04_56_318Z-debug.log
它似乎只是给我们 make fail 错误,我们无法弄清楚。
如有任何建议或帮助,我们将不胜感激。
最佳答案
问题似乎是您使用的 Node 12.x 没有 Node Addons API,但它有 n-api https://nodejs.org/docs/latest-v12.x/api/
文章引用了 Node Addon API https://nodejs.org/api/n-api.html(与nodejs 12.x node版本的n-api不同)
引用https://github.com/nodejs/node-addon-examples适用于 n-api 的示例
关于c++ - 无法运行简单的 N-API hello world 示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58832560/
Closed. This question needs details or clarity。它当前不接受答案。 想改善这个问题吗?添加详细信息,并通过editing this post阐明问题。 去
I am learning boost-python from the Tutorial, 但是报错了,你能给我一些提示吗,谢谢! #include using namespace boost::p
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: Capitalize First Char of Each Word in a String Java 编写进行以下
很抱歉这个问题的措辞有点疯狂,但我对面向代理的思维非常陌生(这些是“模式”吗?),并且对 java 来说只是稍微不那么新鲜,而且我正在努力解决感觉像非常基本的问题。 我“凭直觉”(即盲目地)做了很多这
是的,所以我正在制作一个沼泽标准 Hello world 以确保 android 正常工作。这是我第一次使用 android,所以我正在设置环境。我按照以下程序制作了程序:http://develop
我正在尝试将“Hello World”变为“World Hello”。但是代码没有按照我希望的方式正常工作。请看下面的代码: #include #include #include struct lln
例如,virt-what显示您是否在硬件虚拟化“沙箱”中运行。 如何检测您是否在 ARM "TrustZone"沙箱中运行? 最佳答案 信任专区 可能和你想的不一样。有一个连续的模式。从“受信任功能的
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 6 年前。 Improve this ques
如何使用 CSS 将字符串“Hello world I am Jack”反转为“Jack am I world Hello”? 例如: Hello World ,我是 jack 我想知道如何使用 CS
为什么这段代码抛出 InputMismatchException ? Scanner scanner = new Scanner("hello world"); System.out.println(
require 'csv' s = "\"Hello World\"" CSV.open('output.txt', 'w') do |csv| csv << [s] end 在我的文件中,我
当我尝试这段代码时 char *a[] = {"hello", "world" }; char **p = a; char a[][10]={"hello", "world"}; 我的编译失败了,我被
为什么“第二次世界大战”没有取代“第二次世界大战”? var wha = prompt("What is?"); for (var i = 1; i < wha.length; i++) { if
我刚刚在 Windows XP 上安装了 Python 2.7.2,想学习如何编程。我使用的一些教程书籍提供了打印命令的示例,当我尝试这些命令时,我会得到不同的答案。 我希望这两个返回相同的东西 -
我卸载了android ask并重新安装到没有空格的c:\androidSdktools。所以现在模拟器可以工作了,我可以看到模拟器了。 但尝试了一些“hello world”文本的代码,当我运行应用
在Swift中,下面是什么语法? let (hello, world):(String,String) = ("hello","world") print(hello) //prints "hello
在我的 url 中,我有“?msg=hello+world”,在我的操作中,它将值转换为“hello world” public ActionResult test(string msg) {
正如标题所说,我需要格式化一串文本,格式如下:“HELLO, WORLD. HOW ARE YOU?”进入“你好,世界。你好吗?”,在 iOS 中是否有任何标准方法可以做到这一点?或者有没有示例代码?
我已经开始学习 C++ 并编写了一个“Hello World”程序。当我尝试在命令提示符下运行它时,它崩溃并向我显示一条 Windows 消息“Hello World.exe 已停止工作。”。 代码:
这个问题已经有答案了: member variable string gets treated as Tuple in Python (3 个回答) 已关闭 4 年前。 我是 python 新手,正在
我是一名优秀的程序员,十分优秀!