0
我正在使用本地C++在電子上製作簡單的hello世界應用程序,但得到這個Uncaught Error : error 1114
錯誤。這個錯誤是專門在Windows上運行的項目,而它在Fedora上運行良好。未捕獲的錯誤:電子中的錯誤1114
package.json
:
{
"name": "nodec",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "electron ."
},
"author": "",
"license": "ISC",
"devDependencies": {
"electron-packager": "^8.7.0"
}
}
binding.gyp
:
{
"targets": [
{
"target_name": "addon",
"sources": [ "addon.cc" ]
}
]
}
addon.cc
:
#include <node.h>
namespace demo {
using v8::Exception;
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Number;
using v8::Object;
using v8::String;
using v8::Value;
void hello(const FunctionCallbackInfo& args) {
Isolate* isolate = args.GetIsolate();
args.GetReturnValue().Set(String::NewFromUtf8(isolate,"world"));
}
void Init(Local exports) {
NODE_SET_METHOD(exports, "hello", hello);
}
NODE_MODULE(addon, Init)
}
main.js
:
const addon = require('./build/Release/addon');
console.log('This should be eight:', addon.hello());
index.html
:
<title>My C++ App</title> Hello <script> require('./main.js') </script>
我已經配置,並建立工程幾次,但似乎並沒有被這種情況下很有幫助。