Giter VIP home page Giter VIP logo

Comments (9)

caoxiemeihao avatar caoxiemeihao commented on May 26, 2024 1

我是在主进程使用的execa,并不是在渲染进程,渲染进程ipc调用主进程里的execa

主要进程使用 execa 不用装 vite-plugin-esmodule 这块设计失误。。。
我更新个版本,你稍微当我一小会儿。。。

from electron-vite-boilerplate.

caoxiemeihao avatar caoxiemeihao commented on May 26, 2024 1

代码已经更新 :)

from electron-vite-boilerplate.

spianmo avatar spianmo commented on May 26, 2024

在主进程中,我的execa使用方式

import {execa, Options} from 'execa'

async function _execa(file: string,
                      arguments?: readonly string[],
                      options?: Options<null>) {
    const {stdout} = await execa(file, arguments, options)

    console.log(stdout)
}

from electron-vite-boilerplate.

caoxiemeihao avatar caoxiemeihao commented on May 26, 2024

你确定你的项目在渲染进程开启了 Node.js 能力?

    webPreferences: {
      contextIsolation: false,
      nodeIntegration: true,
    },

from electron-vite-boilerplate.

spianmo avatar spianmo commented on May 26, 2024

你确定你再渲染进程开启了 Node.js 能力?

我是在主进程使用的execa,并不是在渲染进程,渲染进程ipc调用主进程里的execa

from electron-vite-boilerplate.

spianmo avatar spianmo commented on May 26, 2024
nodeIntegration

image

from electron-vite-boilerplate.

spianmo avatar spianmo commented on May 26, 2024

你确定你的项目在渲染进程开启了 Node.js 能力?

    webPreferences: {
      contextIsolation: false,
      nodeIntegration: true,
    },

image

from electron-vite-boilerplate.

caoxiemeihao avatar caoxiemeihao commented on May 26, 2024
  1. packages/main/vite.config.ts
    rollupOptions: {
      external: [
        'electron',
        ...builtinModules,
+       ...builtinModules.map(e => `node:${e}`),
        ...Object.keys(pkg.dependencies || {}),
      ],
    },
  1. execa 放到 devDependencies

这么两步就能用了,你先这么用着;我有事今天不搞了,明天再说。。。

from electron-vite-boilerplate.

spianmo avatar spianmo commented on May 26, 2024
  1. packages/main/vite.config.ts
    rollupOptions: {
      external: [
        'electron',
        ...builtinModules,
+       ...builtinModules.map(e => `node:${e}`),
        ...Object.keys(pkg.dependencies || {}),
      ],
    },
  1. execa 放到 devDependencies

这么两步就能用了,你先这么用着;我有事今天不搞了,明天再说。。。

感谢!

from electron-vite-boilerplate.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.