返回顶部
首页 > 资讯 > 前端开发 > JavaScript >vue-electron使用serialport时问题解决方案
  • 161
分享到

vue-electron使用serialport时问题解决方案

2024-04-02 19:04:59 161人浏览 泡泡鱼
摘要

报错如下: Uncaught TypeError: Cannot read property 'modules' of undefined at Object.eval (webp

报错如下:

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)

总结下来:webpack不能解析二进制什么的...GitHub有讨论


系统: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

重新运行即可

到此这篇关于vue-electron使用serialport时问题解决方案的文章就介绍到这了,更多相关vue-electron使用serialport时问题内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: vue-electron使用serialport时问题解决方案

本文链接: https://lsjlt.com/news/135062.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作