electron / forge

:electron: A complete tool for building and publishing Electron applications
https://electronforge.io
MIT License
6.41k stars 505 forks source link

Command for TypeScript templates broken on Windows #3662

Open Johnrobmiller opened 1 month ago

Johnrobmiller commented 1 month ago

Pre-flight checklist

Electron Forge version

recent

Electron version

recent

Operating system

Windows 11

Last known working Electron Forge version

?

Expected behavior

All templates are broken for me. I tried this command found here

npm init electron-app@latest my-new-app -- --template=webpack-typescript

...as well as all others similar to this. The result is that typescript is not installed. The template is ignored.

This is what I see in my directory: image

Actual behavior

see above

Steps to reproduce

see above

Additional information

No response

erickzhao commented 1 month ago

Hi @Johnrobmiller, I can't seem to reproduce on my side. Can you give me the output from your command and tell me what npm version you're using?

This is the expected output:


♥ 08:55 npm init electron-app@latest my-new-app -- --template=webpack-typescript
✔ Locating custom template: "webpack-typescript"
✔ Initializing directory
✔ Preparing template
✔ Initializing template
✔ Installing template dependencies
walruskhan commented 1 month ago

Having this same issue, template is not installed with node22 (22.4.1), but correctly installed with node16 (v16.20.2), node18 and node20. OS is windows 10.

Below is terminal output for successful project scaffolding.

> npm init electron-app@latest 02-webpack-typescript -- --template=webpack-typescript
Need to install the following packages:
  create-electron-app@7.4.0
Ok to proceed? (y) y
✔ Locating custom template: "webpack-typescript"
✔ Initializing directory
✔ Preparing template
✔ Initializing template
❯ Installing template dependencies
  ✔ Installing production dependencies
  ✔ Installing development dependencies
  ❯ Finalizing dependencies
    ⠋ Installing common dependencies
      › yarn install --dev electron-squirrel-startup
    ◼ Skip linking forge dependencies
erickzhao commented 1 month ago

Thanks for the additional context @walruskhan. I just tried myself on Node.js v22.5.1 and npm 10.8.2 and was unable to reproduce the bug still.

One more avenue to explore is that I'm currently running a macOS device, while both reports so far seem to be on Windows. I'll take a closer look on my Windows machine tomorrow.

jlachniet commented 1 month ago

I had this issue when running this command:

npm init electron-app@latest my-new-app -- --template=vite-typescript

I was able to fix it by running this command instead:

npx create-electron-app my-new-app -- --template=vite-typescript

I am using Windows 11, PowerShell, Node 20.16.0, and npm 10.8.2. It does not appear that the command line args given to npm init are passed along to create-electron-app to use. Here is a full log for reference:

PS D:\test> npm init electron-app@latest test -- --template=vite-typescript

> npx
> create-electron-app test

✔ Locating custom template: "base"
✔ Initializing directory
✔ Preparing template
✔ Initializing template
✔ Installing template dependencies

Edit: I tested the same command on a Linux workstation with the same versions of Node and NPM and it works as expected. So I can confirm this is a Windows only issue.