小编Ari*_*ihu的帖子

如何使 ESM 在我的项目中与 Electron 一起工作?

我已经尝试解决这个问题一周了,但似乎无法真正找到问题。

I've followed this tutorial but instead of having that project structure I've my own (see image below)

项目结构

In the esm.js:

require = require("esm")(module);
module.exports = require("./vickie.js");
Run Code Online (Sandbox Code Playgroud)

Then i've changed vickie.js:
From const { app, BrowserWindow, ipcMain } = require('electron')
To import { app, BrowserWindow, ipcMain } from 'electron'

Then I got this error

电子错误

In package.json:

{
  "name": "vickie",
  "type": "module",
  "version": "0.0.1",
  "description": "",
  "main": "./vickie.js",
  "scripts": {
    "start": "electron ./vickie.js"
  },
  "author": "Arijanit",
  "license": "ISC", …
Run Code Online (Sandbox Code Playgroud)

javascript electron

7
推荐指数
1
解决办法
4165
查看次数

标签 统计

electron ×1

javascript ×1