Skip to content

Vite: External modules not included in packaging #3917

Closed as duplicate
Closed as duplicate

Description

@Bluenix2

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Forge version

7.8.0

Electron version

v35.1.5

Operating system

Windows 11

Last known working Forge version

No response

Expected behavior

Following the Electron Forge documentation, I am configuring external for native node modules. In reality I am trying to use the Auto Unpack Native Modules Plugin but can reproduce the bug the same.

Packages configured as external in the vite config should be copied during packaging into a node_modules folder. Since they are not bundled by Vite normally.

Actual behavior

The packages are instead omitted from the produced package, resulting in errors trying to start Electron.

Steps to reproduce

  1. Create a project from the Vite template: npx create-electron-app@latest my-electron-forge-app --template=vite
  2. Install a testing package: npm install is-odd
  3. Add the following code to main.js:
import isOdd from 'is-odd';

console.log(isOdd(1));
  1. Update vite.main.config.mjs:
import { defineConfig } from 'vite';

// https://vitejs.dev/config
export default defineConfig({
  build: {
    rollupOptions: {
      external: [
        'is-odd',
      ]
    }
  }
});
  1. Package the app, and attempt to run the executable: npm run package

Additional information

No response

Activity

  1. added theissue type on Apr 15, 2025
  2. webrtcn commented on Apr 24, 2025

    @webrtcn

    #3738 same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions