forge icon indicating copy to clipboard operation
forge copied to clipboard

Command for TypeScript templates broken on Windows

Open Johnrobmiller opened this issue 1 year ago • 5 comments

Pre-flight checklist

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

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

Johnrobmiller avatar Jul 21 '24 18:07 Johnrobmiller

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

erickzhao avatar Jul 22 '24 15:07 erickzhao

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:
  [email protected]
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

walruskhan avatar Jul 22 '24 22:07 walruskhan

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.

erickzhao avatar Jul 22 '24 23:07 erickzhao

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.

jlachniet avatar Aug 03 '24 00:08 jlachniet

Problem persists, however it only seems to occur using powershell and/or cmd, using git bash causes no issues.

VanMonten avatar Sep 12 '24 15:09 VanMonten

Can this issue's title be changed to "Commands for creating templates broken on windows"? It would be more helpful as the bug effects all templates rather than only TypeScript.

lunaDHD avatar Dec 11 '24 17:12 lunaDHD

Problem persists, however it only seems to occur using powershell and/or cmd, using git bash causes no issues.

Tested on latest version, powershell and cmd are broken still, so using git bash is still the best option.

lunaDHD avatar Dec 11 '24 17:12 lunaDHD

Going to replace the commands with the npx invocation since this seems to be a weird upstream Node 22 bug.

erickzhao avatar Dec 11 '24 18:12 erickzhao