vue-electron使用serialport時(shí)問題解決方案
報(bào)錯(cuò)如下:
Uncaught TypeError: Cannot read property 'modules' of undefined
at Object.eval (webpack-internal:///./node_modules/bindings/bindings.js:29)
at eval (webpack-internal:///./node_modules/bindings/bindings.js:223)
at Object../node_modules/bindings/bindings.js (chunk-vendors.js:255)
at __webpack_require__ (app.js:849)
at fn (app.js:151)
at eval (webpack-internal:///./node_modules/@serialport/bindings/lib/linux.js:2)
at Object../node_modules/@serialport/bindings/lib/linux.js (chunk-vendors.js:65)
at __webpack_require__ (app.js:849)
at fn (app.js:151)
at Object.eval (webpack-internal:///./node_modules/@serialport/bindings/lib/index.js:14)
總結(jié)下來:webpack不能解析二進(jìn)制什么的...github有討論
系統(tǒng):win10
"dependencies": {
"core-js": "^3.6.5",
"electron-prebuilt": "^1.4.13",
"serialport": "^9.2.1",
"vue": "^2.6.11"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"electron": "^13.0.0",
"electron-devtools-installer": "^3.1.0",
"electron-rebuild": "^3.2.3",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-cli-plugin-electron-builder": "~2.1.1",
"vue-template-compiler": "^2.6.11"
},
解決方法:
const { IgnorePlugin } = require('webpack')
module.exports = {
pluginOptions: {
plugins: [
new IgnorePlugin({
resourceRegExp: /serialport/
})
],
electronBuilder: {
nodeIntegration: true,
externals: [
'serialport'
]
}
}
}

app.allowRendererProcessReuse = false

重新運(yùn)行即可


到此這篇關(guān)于vue-electron使用serialport時(shí)問題解決方案的文章就介紹到這了,更多相關(guān)vue-electron使用serialport時(shí)問題內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
vue基于better-scroll實(shí)現(xiàn)左右聯(lián)動(dòng)滑動(dòng)頁面
這篇文章主要介紹了vue基于better-scroll實(shí)現(xiàn)左右聯(lián)動(dòng)滑動(dòng)頁面,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-06-06
vue項(xiàng)目中自動(dòng)導(dǎo)入svg并愉快的使用方式
這篇文章主要介紹了vue項(xiàng)目中自動(dòng)導(dǎo)入svg并愉快的使用方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-11-11
vue+element開發(fā)一個(gè)谷歌插件的全過程
這篇文章主要給大家介紹了關(guān)于vue+element開發(fā)一個(gè)谷歌插件的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-05-05
windows下vue-cli導(dǎo)入bootstrap樣式
這篇文章主要介紹了windows下vue-cli導(dǎo)入bootstrap樣式,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-04-04

