描述

使用Electron+Vue项目时引入serialport串口后启动时报下面错误

Cannot read property 'indexOf' of undefined

解决方法

打开vue.config.js找到pluginOptions -> electronBuilder -> externals添加serialport

module.exports = {pluginOptions: {electronBuilder: {externals: ['serialport'],}}}