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

Can't build on Windows when using a JS file for config. #6227

Closed
jedieaston opened this issue Sep 3, 2021 · 10 comments · Fixed by #6341
Closed

Can't build on Windows when using a JS file for config. #6227

jedieaston opened this issue Sep 3, 2021 · 10 comments · Fixed by #6341

Comments

@jedieaston
Copy link

  • Electron-Builder Version: 22.11.11 (4.4.3)
  • Node Version: 14.17.1
  • Electron Version: 14.0.0
  • Electron Type (current, beta, nightly): current
  • Target: Windows

I'm attempting to run electron-builder using a JS file for config (so I have access to process.ENV, which isn't available in yaml files). Attempting to run any electron-builder command on Windows results in a JScript error (which is super weird unless somehow electron-builder is trying to execute the file without node). The screenshot was taken after running npx electron-builder from PowerShell at the project root:

image

For reference, here's my electron-builder.js:

const config = {
    appId: "im.hmt.report.schild",
    productName: "schild.report",
    artifactName: "schild.report.${ext}",
    buildVersion: `2.5.${process.env.GITHUB_RUN_NUMBER}`,
    copyright: `Copyright ${process.env.THE_AUTHOR}`,
    extraMetadata: {
        author: {
            name: `${process.env.THE_AUTHOR}`,
            email: `${process.env.THE_EMAIL}`
        }
    },
    files: [
        "./build/**/*"
    ],
    win: {
        icon: "icons/icon.ico",
        target: "msi"
    },
    linux: {
        icon: "icons/icon.png",
        category: "app.tools",
        executableName: "schild.report",
        target: [
            "AppImage",
            "snap",
            "deb",
            "rpm"
        ]
    },
    mac: {
        icon: "icons/icon.icns",
        target: "dmg"
    },
    dmg: {
        icon: "icons/icon.icns",
        contents: [
            {
                x: 130,
                y: 220
            },
            {
                x: 550,
                y: 22,
                type: "link",
                path: "/Applications"
            }
        ],
        window: {
            width: 680,
            height: 42
        }
    }
}
module.exports = config

This also happens on GitHub Actions hosted runners, so it's not my machine.

@ahadcove
Copy link

We're currently running into this same issue

@ahadcove
Copy link

Seems like the node version was causing issues. Try downgrading to node 14 and the build should go through without any issues

@hmt
Copy link

hmt commented Sep 13, 2021

As stated above this is node 14. What's the exact version you're using?

@IhorKobylinskiy
Copy link

Have the same issue. Tried with different node versions.

@onikienko
Copy link
Contributor

I think the problem is in the config file name. Do not use electron-builder.js name. Name it to say electron-builder-config.js.

And run like electron-builder --config electron-builder-config.js.

@jedieaston
Copy link
Author

That worked! I'm going to leave this open because it's definitely a bug, but thanks for figuring that out.

@onikienko
Copy link
Contributor

onikienko commented Oct 13, 2021

There is a collision with the file name and module path resolution. When you run electron-builder command it runs your electron-builder.js file with build config instead of the electron-builder package from node_modules.

It requires an update in the documentation.

I will send PR for this.

@mmaietta
Copy link
Collaborator

mmaietta commented Oct 17, 2021

I'm going to leave this open because it's definitely a bug

I still wholly disagree that this is due to it being an electron-builder-specific issue, as my project builds on linux/win/mac machines using a config file named electron-builder.js without any issues. Same with using a electron-builder.yaml and I've tested it using both npm and yarn.

I'm wondering if this is windows-specific and needs to be in a specific env, such as powershell?

@jedieaston
Copy link
Author

I run from Windows PowerShell 5.1. I haven't had this issue with any other Node packages before, although the fact that renaming the file to something that isn't electron-builder.js makes it work is extremely weird. Maybe npm/npx is mangling the path somehow, and directing electron-builder to ./electron-builder.js somehow?

@fairking
Copy link

The following might be related and could help to solve the problem: ficonsulting/RInno#44 (comment)

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.

7 participants