我所有的源码都在这里供参考:
https://github.com/xkenneth/electron-react-blueprint-bp
我已经建立了一个很好的样板建立使用电子锻造TypeScript + Webpack模板
https://www.electronforge.io/templates/typescript-+-webpack-template
然后跟随
https://www.electronforge.io/guides/framework-integration/react-with-typescript
现在,我正在尝试为用户界面加载BluePrintJS
当我运行我的代码时,我得到以下错误:
index.js:2393 Uncaught ReferenceError: process is not defined

我按照这里的说明做了,但没有用。
Webpack: Bundle.js - Uncaught ReferenceError: process is not defined
有什么想法吗?
这是我的app.jsx
import { Divider } from '@blueprintjs/core';
console.log('Importing react.')
import * as React from 'react';
import * as ReactDOM from 'react-dom';
console.log('Importing BluePrint')
import { Button, Intent, Spinner } from "@blueprintjs/core";
function App () {
return (<div>
<div>Well, just go $#@! yourself!</div>
<div><Button></Button></div>
</div>
)
}
function render() {
ReactDOM.render(<App/>, document.getElementById("root"));
}
render();这是我的web pack.main.config.js (我假设此样板使用web pack.main.config.js,因为我找不到web pack.config.js
const webpack = require('webpack')
module.exports = {
/**
* This is the main entry point for your application, it's the first file
* that runs in the main process.
*/
entry: './src/index.ts',
// Put your normal webpack config below here
module: {
rules: require('./webpack.rules'),
},
resolve: {
extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json'],
alias: {
process: "process/browser"
},
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development')
})
],
};发布于 2021-07-27 21:37:48
我将这行代码添加到src/renderer.ts的顶部,它工作得很好!
window.process ={ env:{} } as NodeJS.Process;
https://stackoverflow.com/questions/68539538
复制相似问题