Electron Builder with React:Getting __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED

kxe2p93d  于 11个月前  发布在  Electron
关注(0)|答案(1)|浏览(177)

我正在使用Electron Builder打包我的React应用程序,但我得到了这个错误:

Uncaught TypeError: Cannot read properties of undefined (reading '__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED')
at 289 (react-jsx-runtime.production.min.js:10:136)
at d (bootstrap:19:22)
at 115 (jsx-runtime.js:4:20)
at d (bootstrap:19:22)
at make namespace object:6:63
at index.tsx:8:17
at index.tsx:8:17
at universalModuleDefinition:7:233
at universalModuleDefinition:1:1

字符串
错误似乎源于index.tsx的最后一行:

import React from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
import { All_Channels } from '../main/preload';

const container = document.getElementById('root') as HTMLElement;
const root = createRoot(container);
root.render(<App />);


我的构建结构是这样的:

release
├── app
├── dist
│   └── main
│       ├── main.js
│       ├── main.js.map
│       ├── preload.js
│       └── preload.js.map
└── renderer
    ├── index.html
    ├── renderer.js
    ├── renderer.js.LICENSE.txt
    ├── renderer.js.map
    ├── search.html
    ├── style.css
    └── style.css.map
node_modules
├── package-lock.json
├── package.json
└── yarn.lock


我在dist的node_modules中看到了React,所以我不知道为什么它找不到我的应用程序。
下面是我的Electron-Builder配置,它被设置为package.json中的“build”属性:

"build": {
"productName": "ElectronReact",
"appId": "org.erb.ElectronReact",
"asar": true,
"asarUnpack": "**\\*.{node,dll}",
"afterSign": ".erb/scripts/notarize.js",
"mac": {
  "target": {
    "target": "default",
    "arch": [
      "arm64"
    ]
  },
  "type": "distribution",
  "hardenedRuntime": true,
  "entitlements": "assets/entitlements.mac.plist",
  "entitlementsInherit": "assets/entitlements.mac.plist",
  "gatekeeperAssess": false
},
"dmg": {
  "contents": [
    {
      "x": 130,
      "y": 220
    },
    {
      "x": 410,
      "y": 220,
      "type": "link",
      "path": "/Applications"
    }
  ]
},
"win": {
  "target": [
    "nsis"
  ]
},
"linux": {
  "target": [
    "AppImage"
  ],
  "category": "Development"
},
"directories": {
  "app": "release/app",
  "buildResources": "assets",
  "output": "release/build"
},
"extraResources": [
  "./assets/**"
],
"includeSubNodeModules": true,
"publish": {
  "provider": "github",
  "owner": "electron-react-boilerplate",
  "repo": "electron-react-boilerplate"
}}

pes8fvy9

pes8fvy91#

@Arkellys让我走上了正确的道路。package.json添加files并没有修复它(但它是一个因素)。为了修复另一个bug,我修改了一个webpack文件中的一些东西,导致了现在的问题。
我去了electron-react-boilerplate,把我所有的webpack文件都改成了原来的。

相关问题