Cljs project using Figwheel on Windows

Created a new project

lein new figwheel <projname> -- --reagent

then

run lein figwheel

Following error comes

Compiling build :dev to "resources/public/js/compiled/out/index.js" from ["src"]...
Failed to compile build :dev from ["src"] in 38.449 seconds.
----  Exception    ----

  clojure.lang.ExceptionInfo : :build-cmd :none failed
         java.io.IOException : Cannot run program "npx": CreateProcess error=2, The system cannot find the file specified
         java.io.IOException : CreateProcess error=2, The system cannot find the file specified

----  Exception Stack trace....

Also has installed node.js
WIndows 10 OS

What’s issue ? pl help

Thanks in advance

java.io.IOException : Cannot run program “npx”: CreateProcess error=2, The system cannot find the file specified

Looks like you need to install npx: npm install -g npx

Might be a bug in figwheel, not your fault. npx is actually npx.cmd on Windows so it won’t find it under npx. You might have more success when you run everything in WSL.

1 Like

Is there any other option of using figwheel under Windows OS

installed npx ,but not error mesg. is shown as

----  Exception    ----

  clojure.lang.ExceptionInfo : :build-cmd :none failed
         java.io.IOException : Cannot run program "npx": CreateProcess error=2, The system cannot find the file specified
         java.io.IOException : CreateProcess error=2, The system cannot find the file specified

----

I second @thheller’s suggestion:

I would recommend you to install WSL2 and do all your development there.

E.g.

  1. Use the new Windows terminal to enter wsl shell.
  2. For convenient code editing you can use: htps://code.visualstudio.com/docs/remote/wsl
  3. You can expose your dev server ports and browse the site from Windows.

IMO it is better time invested than trying to work around random Windows issues because only few people use those tools (directly) under Windows.

1 Like

I do use Windows myself so I can say that shadow-cljs works just fine there even with WSL. Would still recommend it though.

@abevahd in your project.clj try switching the :bundle-cmd to use npx.cmd instead of npx.

 :bundle-cmd {:none ["npx" "webpack" "--mode=development"]
              :default ["npx" "webpack"]}

to

 :bundle-cmd {:none ["npx.cmd" "webpack" "--mode=development"]
              :default ["npx.cmd" "webpack"]}

Maybe thats enough?

This works …

Thanks a lot

1 Like

It’s amazing to me that the solution for developing on Windows becomes “install Linux”. I get why, but it does concern me.

1 Like

I’m using WSL and switched to WSL2. But the filesystem performance of WSL2 is so abysmal that I had to converted back to WSL. The problem is known. The github issue is a novel. I cannot recommend WSL2 for file I/O intense apps - eg. git projects with many files.

1 Like

You can develop on Windows, like Clojure and ClojureScript both run. The issue is there isn’t as much tooling being tested or thought out for Windows. This opens up the door for Windows users in the community to help out with testing tooling on Windows and contributing patches if there are any bugs.

Sure, it has some rough edges. Not sure what you were doing, but it works nicely when following this rule:

With WSL2 (at the moment) you should be working on native linux filesystem (e.g in /home/$LINUX_USER not in /mnt/c/Users/$WIN_USER - which is a slow plan9 mount) and when you rarely need to access the files from Windows side, you go through \\wsl$ network drive visible in Windows. So for example doing git status must be done on linux side via terminal (or via special support in VS code), running git status on windows side e.g. from \\wsl$\home\$LINUX_USER is a bad idea.

1 Like