我正在尝试在装有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-loader
和raw-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();
}
}