【发布时间】:2020-10-09 12:29:37
【问题描述】:
我刚刚使用以下命令创建了一个新应用程序:
npx create-electron-app my-new-app --template=typescript-webpack
在 renderer.ts 我添加了以下代码
import "./index.css";
import { ipcRenderer } from "electron";
但是当我运行 npm run start 我在浏览器控制台中出现以下错误
Uncaught ReferenceError: require is not defined
更新 我试过的:
webpack.plugins.js
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
const webpack = require("webpack");
module.exports = [
new ForkTsCheckerWebpackPlugin(),
new webpack.ExternalsPlugin("commonjs", ["electron"]),
];
但还是不行。
【问题讨论】:
标签: node.js electron electron-forge