Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn package stalls if missing mandatory fields #3128

Closed
3 tasks done
mrleblanc101 opened this issue Jan 1, 2023 · 4 comments · Fixed by #3136
Closed
3 tasks done

yarn package stalls if missing mandatory fields #3128

mrleblanc101 opened this issue Jan 1, 2023 · 4 comments · Fixed by #3136

Comments

@mrleblanc101
Copy link

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.

Electron Forge version

6.0.4

Electron version

v22.0.0

Operating system

macOS 13.0.1 (Apple Silicon)

Last known working Electron Forge version

N/A

Expected behavior

When I run yarn run package or yarn run make, the CLI never ends.
The app should be build in a reasonable amount of time.
I'm on a 14" MacBook Pro with M1 Pro and 32GB of RAM.
The CPU usage is unusually low...
Capture d’écran, le 2023-01-01 à 03 29 36
Capture d’écran, le 2023-01-01 à 03 23 23

Actual behavior

I ran the auto importer in my Nuxt 3 app.

yarn add --dev @electron-forge/cli
npx electron-forge import

I added the key main to package.json and created my main.js entry point.
When I run yarn run start, my app launch correctly.
When I run yarn run package or yarn run make, the CLI never ends.

Steps to reproduce

// package.json
{
    "private": true,
    "version": "1.0.0",
    "main": "main.js",
    "scripts": {
        "build": "nuxt build",
        "dev": "nuxt dev",
        "generate": "nuxt generate",
        "preview": "nuxt preview",
        "postinstall": "nuxt prepare",
        "start": "electron-forge start",
        "package": "electron-forge package",
        "make": "electron-forge make"
    },
    "devDependencies": {
        "@electron-forge/cli": "^6.0.4",
        "@electron-forge/maker-deb": "^6.0.4",
        "@electron-forge/maker-rpm": "^6.0.4",
        "@electron-forge/maker-squirrel": "^6.0.4",
        "@electron-forge/maker-zip": "^6.0.4",
        "@nuxtjs/color-mode": "^3.2.0",
        "@nuxtjs/google-fonts": "^3.0.0-1",
        "@nuxtjs/i18n": "^8.0.0-beta.7",
        "@nuxtjs/tailwindcss": "^6.2.0",
        "@pinia-plugin-persistedstate/nuxt": "^1.0.0",
        "@types/file-saver": "^2.0.5",
        "@types/inputmask": "^5.0.3",
        "@types/moment": "^2.13.0",
        "@types/moment-duration-format": "^2.2.3",
        "@types/uuid": "^9.0.0",
        "electron": "^22.0.0",
        "nuxt": "3.0.0",
        "postcss-import": "^15.1.0",
        "prettier": "^2.8.1",
        "vite-svg-loader": "^4.0.0"
    },
    "dependencies": {
        "@pinia/nuxt": "^0.4.6",
        "@vueform/multiselect": "^2.5.8",
        "electron-serve": "^1.1.0",
        "electron-squirrel-startup": "^1.0.0",
        "file-saver": "^2.0.5",
        "inputmask": "^5.0.7",
        "moment": "^2.29.4",
        "moment-duration-format": "^2.3.2",
        "uuid": "^9.0.0",
        "vue3-click-away": "^1.2.4"
    }
}
// main.js

const { app, BrowserWindow } = require('electron');
const serve = require('electron-serve');

const loadURL = serve({ directory: '.output/public/' });

const createWindow = async () => {
    const { screen } = require('electron');
    const primaryDisplay = screen.getPrimaryDisplay();
    const { width, height } = primaryDisplay.workAreaSize;

    const win = new BrowserWindow({
        minWidth: 375,
        minHeight: 600,
        width,
        height,
        show: false,
        webPreferences: {
            contextIsolation: true,
            nodeIntegration: false,
            nodeIntegrationInWorker: true,
            sandbox: true,
        },
    });

    await loadURL(win);

    win.webContents.on('did-finish-load', () => {
        win.show();
    });
};

app.whenReady().then(async () => {
    await createWindow();

    app.on('activate', async () => {
        if (BrowserWindow.getAllWindows().length === 0) {
            await createWindow();
        }
    });
});

app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
        app.quit();
    }
});
// forge.config.js
module.exports = {
  packagerConfig: {},
  rebuildConfig: {},
  makers: [
    {
      name: '@electron-forge/maker-squirrel',
      config: {},
    },
    {
      name: '@electron-forge/maker-zip',
      platforms: ['darwin'],
    },
    {
      name: '@electron-forge/maker-deb',
      config: {},
    },
    {
      name: '@electron-forge/maker-rpm',
      config: {},
    },
  ],
};

Additional information

» yarn make
yarn run v1.22.19
$ DEBUG=electron-forge:* electron-forge make
⠋ Checking your system
✔ Checking your system
[STARTED] Loading configuration
  electron-forge:project-resolver searching for project in: /Users/sleblanc/Github/neobigben +0ms
  electron-forge:project-resolver package.json with forge dependency found in /Users/sleblanc/Github/neobigben/package.json +0ms
[SUCCESS] Loading configuration
[STARTED] Resolving make targets
  electron-forge:require-search searching [
  '@electron-forge/maker-squirrel',
  '/Users/sleblanc/Github/neobigben/@electron-forge/maker-squirrel',
  '/Users/sleblanc/Github/neobigben/node_modules/@electron-forge/maker-squirrel'
] relative to /Users/sleblanc/Github/neobigben +0ms
  electron-forge:require-search testing @electron-forge/maker-squirrel +1ms
  electron-forge:require-search searching [
  '@electron-forge/maker-zip',
  '/Users/sleblanc/Github/neobigben/@electron-forge/maker-zip',
  '/Users/sleblanc/Github/neobigben/node_modules/@electron-forge/maker-zip'
] relative to /Users/sleblanc/Github/neobigben +7ms
  electron-forge:require-search testing @electron-forge/maker-zip +1ms
  electron-forge:require-search searching [
  '@electron-forge/maker-deb',
  '/Users/sleblanc/Github/neobigben/@electron-forge/maker-deb',
  '/Users/sleblanc/Github/neobigben/node_modules/@electron-forge/maker-deb'
] relative to /Users/sleblanc/Github/neobigben +0ms
  electron-forge:require-search testing @electron-forge/maker-deb +0ms
  electron-forge:require-search searching [
  '@electron-forge/maker-rpm',
  '/Users/sleblanc/Github/neobigben/@electron-forge/maker-rpm',
  '/Users/sleblanc/Github/neobigben/node_modules/@electron-forge/maker-rpm'
] relative to /Users/sleblanc/Github/neobigben +0ms
  electron-forge:require-search testing @electron-forge/maker-rpm +0ms
[DATA] Making for the following targets: zip
[SUCCESS] Resolving make targets
[STARTED] Running package command
[STARTED] Preparing to package application
  electron-forge:project-resolver searching for project in: /Users/sleblanc/Github/neobigben +13ms
  electron-forge:project-resolver package.json with forge dependency found in /Users/sleblanc/Github/neobigben/package.json +1ms
[SUCCESS] Preparing to package application
[STARTED] Running packaging hooks
[STARTED] Running generateAssets hook
[SUCCESS] Running generateAssets hook
[STARTED] Running prePackage hook
[SUCCESS] Running prePackage hook
[SUCCESS] Running packaging hooks
[STARTED] Packaging application
[DATA] Determining targets...
  electron-forge:packager packaging with options {
  asar: false,
  overwrite: true,
  ignore: [ /^\/out\//g ],
  quiet: true,
  dir: '/Users/sleblanc/Github/neobigben',
  arch: 'arm64',
  platform: 'darwin',
  afterFinalizePackageTargets: [ [AsyncFunction (anonymous)] ],
  afterComplete: [ [AsyncFunction (anonymous)] ],
  afterCopy: [ [AsyncFunction (anonymous)] ],
  afterExtract: [ [AsyncFunction (anonymous)] ],
  afterPrune: [ [AsyncFunction (anonymous)] ],
  out: '/Users/sleblanc/Github/neobigben/out',
  electronVersion: '22.0.0'
} +0ms
✨  Done in 0.81s.

 ~/Github/neobigben   main *1 !2 ?3                                                          ✔  03:30:31
» yarn package
yarn run v1.22.19
$ DEBUG=electron-forge:* electron-forge package
⠋ Checking your system
✔ Checking your system
[STARTED] Preparing to package application
  electron-forge:project-resolver searching for project in: /Users/sleblanc/Github/neobigben +0ms
  electron-forge:project-resolver package.json with forge dependency found in /Users/sleblanc/Github/neobigben/package.json +0ms
[SUCCESS] Preparing to package application
[STARTED] Running packaging hooks
[STARTED] Running generateAssets hook
[SUCCESS] Running generateAssets hook
[STARTED] Running prePackage hook
[SUCCESS] Running prePackage hook
[SUCCESS] Running packaging hooks
[STARTED] Packaging application
[DATA] Determining targets...
  electron-forge:packager packaging with options {
  asar: false,
  overwrite: true,
  ignore: [ /^\/out\//g ],
  quiet: true,
  dir: '/Users/sleblanc/Github/neobigben',
  arch: 'arm64',
  platform: 'darwin',
  afterFinalizePackageTargets: [ [AsyncFunction (anonymous)] ],
  afterComplete: [ [AsyncFunction (anonymous)] ],
  afterCopy: [ [AsyncFunction (anonymous)] ],
  afterExtract: [ [AsyncFunction (anonymous)] ],
  afterPrune: [ [AsyncFunction (anonymous)] ],
  out: '/Users/sleblanc/Github/neobigben/out',
  electronVersion: '22.0.0'
} +0ms
✨  Done in 0.71s.
@mrleblanc101
Copy link
Author

Here is my app when I use yarn start, works fine and no errors.
Capture d’écran, le 2023-01-01 à 03 32 24
Capture d’écran, le 2023-01-01 à 03 32 24 (2)

@mrleblanc101
Copy link
Author

I found the issue,
name and productName are mandatory, but there is no error if they are missing.
The build will just never start.

@erickzhao erickzhao changed the title yarn run make never finish yarn package stalls if missing mandatory fields Jan 3, 2023
@erickzhao
Copy link
Member

erickzhao commented Jan 3, 2023

Thanks for the report @mrleblanc101! The CLI should definitely give you feedback and cancel the package operation if those fields are missing.

Separately, we should probably also add the name and productName fields in package.json in the import script if those are missing.

@mrleblanc101
Copy link
Author

Yep, I created my project using nuxi the Nuxt 3 CLI instead of npm init so that's why name, version and a few other fields were missing.

Someone on the Electron discord helped me figure it out, thanks !

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

Successfully merging a pull request may close this issue.

2 participants