reactjs - 与 webpack 捆绑后的电子远程错误
问题描述
我在 React 的帮助下制作了一个 Electron 应用程序,但是在导入 Electron 的远程模块后,在将代码与 webpack 捆绑后,我不断收到以下错误:
Uncaught TypeError: r.existsSync is not a function
代码如下:
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import * as path from 'path'
import {remote} from 'electron'
import Application from './components/Application'
const appRoot = document.getElementById('app-root')
console.log(remote.getGlobal('mainRoot'))
ReactDOM.render(
<Application />,
appRoot
)
网络包配置:
const path = require('path');
module.exports = {
entry: './templates/js/test.js',
output: {
path: path.join(__dirname, 'templates/dist'),
filename: 'test.js'
},
watch: true,
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: "babel-loader"
}, {
test: /\.jsx?$/,
exclude: /node_modules/,
use: "babel-loader"
}
]
}
}
解决方案
推荐阅读
- sql - 即使 SQL Browser 服务正在运行,在 SSAS 中也会收到“确保 'SQL Browser 服务'正在运行”错误
- java - 如何知道点是在线的右侧还是左侧
- azure-data-factory - 如何解释 Azure 数据工厂中的 indexof 表达式和函数
- laravel - Laravel Iamge 验证 jpeg 失败
- c++ - 命名空间问题和IDE之间的区别
- kdb - 在 KDB 中,如何将列表中的前 3 个数字相加?
- java - spring boot 执行 data.sql 和 schema.sql 两次?
- java - 为什么在调用 .show() 时使用在构造函数中传递的自定义组件创建弹出对话框显示空白对话框?
- python - 从反应到烧瓶的发布请求
- ios - 将数据传递给 VNCoreMLRequest