【发布时间】:2020-05-09 13:13:34
【问题描述】:
我使用n-api 编写了一个c++ 模块,使用cmake-js 编译它,现在想在我的electron-vue 应用程序中使用它。如果我在没有electron-vue 的项目中使用该模块,它可以工作。但是当我尝试在我的 electron-vue 应用程序中使用它时,我总是会收到这个错误:
App threw an error during load
TypeError: Cannot read property 'indexOf' of undefined
at Function.getFileName (D:\temp\test2\node_modules\bindings\bindings.js:178:16)
at bindings (D:\temp\test2\node_modules\bindings\bindings.js:82:48)
at eval (webpack:///./src/main/index.js?:28:67)
at Module../src/main/index.js (D:\temp\test2\dist\electron\main.js:3822:1)
at __webpack_require__ (D:\temp\test2\dist\electron\main.js:21:30)
at eval (webpack:///./src/main/index.dev.js?:11:1)
at Object../src/main/index.dev.js (D:\temp\test2\dist\electron\main.js:3810:1)
at __webpack_require__ (D:\temp\test2\dist\electron\main.js:21:30)
at eval (webpack:///multi_./src/main/index.dev.js_./src/main/index.js?:1:1)
at Object.0 (D:\temp\test2\dist\electron\main.js:3880:1)
我像这样使用bindings:
const colorBalance = require('bindings')('colorBalance');
我尝试根据this 将我的模块定义为外部模块,但没有解决问题:
// vue.config.js
module.exports = {
pluginOptions: {
electronBuilder: {
externals: ['NameOfMyModule']
}
}
}
【问题讨论】:
标签: vue.js cmake electron n-api