./node_modules/node-pty/build/Release/pty.node 模块解析失败:意外字符 ''

./node_modules/node-pty/build/Release/pty.node Module parse failed: Unexpected character ''

我正在尝试在使用 vue-cli 构建的项目中使用库 node-pty。当我启动程序时出现以下错误:

error in ./node_modules/node-pty/build/Release/pty.node

Module parse failed: Unexpected character '' (1:0) 
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders 
(Source code omitted for this binary file)

@ ./node_modules/node-pty/lib/index.js 49:49-85 
@ ./src/background.js

重现步骤

vue create test-project
cd test-project && vue add electron-builder
npm i node-pty@beta

import pty from 'node-pty’添加到src/background.js

npm run electron:serve

我的尝试

我试图将 node-loaderraw-loader 添加到 vue.config.js 文件

configureWebpack: {
  chainWebpack: config => {
    config.module
      .rule('node')
      .test(/.node$/i)
      .use('node-loader')
      .loader('node-loader')
      .end()
  }
}

这不能解决问题。

vue.config.js需要使用module.exports

module.exports = {
  chainWebpack: config => {
    config.module
      .rule('node')
      .test(/\.node$/)
      .use('node-loader')
      .loader('node-loader')
      .end();
  }
}