首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Electron + React运行BluePrintJS时出错

使用Electron + React运行BluePrintJS时出错
EN

Stack Overflow用户
提问于 2021-07-27 13:45:00
回答 1查看 50关注 0票数 0

我所有的源码都在这里供参考:

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

当我运行我的代码时,我得到以下错误:

代码语言:javascript
复制
index.js:2393 Uncaught ReferenceError: process is not defined

我按照这里的说明做了,但没有用。

Webpack: Bundle.js - Uncaught ReferenceError: process is not defined

有什么想法吗?

这是我的app.jsx

代码语言:javascript
复制
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

代码语言:javascript
复制
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')
    })
],
};
EN

回答 1

Stack Overflow用户

发布于 2021-07-27 21:37:48

我将这行代码添加到src/renderer.ts的顶部,它工作得很好!

window.process ={ env:{} } as NodeJS.Process;

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68539538

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档