vue-electron problem solution when using serialport

vue-electron problem solution when using serialport

The error is as follows:

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)

To sum up: webpack can't parse binary or something... There is a discussion on github

System: 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"
},

Solution:

const { IgnorePlugin } = require('webpack')
 
module.exports = {
  pluginOptions: {
    plugins: [
      new IgnorePlugin({
        resourceRegExp: /serialport/
      })
    ],
    electronBuilder: {
      nodeIntegration: true,
      externals: [
        'serialport'
      ]
    }
  }
} 

app.allowRendererProcessReuse = false 

Just re-run

This is the end of this article about solutions to problems when vue-electron uses serialport. For more related content about problems when vue-electron uses serialport, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of desktop application using Vue3 and Electron
  • Detailed explanation of client configuration for vue3+electron12+dll development
  • An example of how to build a local player from scratch using Electron+vue
  • Solution to callback in dialog of electron pitfall
  • Solution to electron's remote of undefined problem
  • Detailed graphic explanation of the construction process of Electron project based on Vue

<<:  Detailed explanation of the usage of grep command in Linux

>>:  Is mysql a relational database?

Recommend

How to export CSV file with header in mysql

Refer to the official document http://dev.mysql.c...

WHMCS V7.4.2 Graphical Installation Tutorial

1. Introduction WHMCS provides an all-in-one solu...

Not all pop-ups are rogue. Tips on designing website pop-ups

Pop-up news is common in domestic Internet servic...

Docker completely deletes private library images

First, let’s take a look at the general practices...

You may need a large-screen digital scrolling effect like this

The large-screen digital scrolling effect comes f...

Mount the disk in a directory under Ubuntu 18.04

Introduction This article records how to mount a ...

Install nvidia graphics driver under Ubuntu (simple installation method)

Install the nvidia graphics card driver under Ubu...

Usage instructions for the docker create command

The docker create command can create a container ...

Example code for implementing background blur effect with CSS

Is it the effect below? If so, please continue re...

Complete steps for deploying confluence with docker

Confluence is paid, but it can be cracked for use...

Method of realizing automated deployment based on Docker+Jenkins

Use Code Cloud to build a Git code storage wareho...

A brief discussion on docker-compose network settings

Networks usage tutorial Official website docker-c...

Implementation of docker redis5.0 cluster cluster construction

System environment: Ubuntu 16.04LTS This article ...

Pay attention to the use of HTML tags in web page creation

HTML has attempted to move away from presentation...

MySQL 8.0.21 free installation version configuration method graphic tutorial

Six steps to install MySQL (only the installation...