Running ClojureScript: Unable to locate cljs/main.clj
Asked Answered
T

5

8

Total rookie here. I am trying to run ClojureScript for the first time and followed the quickstart tutorial. However, upon entering...

clj --main cljs.main --compile hello-world.core --repl

I get the following error message:

Execution error (FileNotFoundException) at clojure.main/main (main.java:40).
FileNotFoundException: Could not locate cljs/main__init.class or cljs/main.clj on classpath.
Teryl answered 28/4, 2018 at 16:3 Comment(3)
You need to specify which platform, it's different between windows and *nix.Isbella
I had the same issue, I had a deps file with the clojurescript dependency. The reason it didn't work for me is I was running the clj command in the src directory. I switched to the directory containing the deps file and it worked instantly.Spring
@nakamin Excellent.Labour
N
4

It can’t find the cljs.main in the Clojurescript jar. As the QuickStart mentions, you need a deps.edn for Mac/Linux or the cljs.jar for Windows.

Nash answered 30/4, 2018 at 2:15 Comment(0)
K
2

Make sure you are in the hello-world project directory and run the following command....

Docs are wrong, run the command on the root where deps.edn exist

Koralle answered 2/10, 2021 at 13:7 Comment(0)
T
1

This error surfaces when one runs clj --main cljs.main --compile hello-world.core --repl from directory or path which does not have file deps.end or cljs.jar.

Considering the directory structure at https://clojurescript.org/guides/quick-start,

hello-world  #### Run that command in this directory
├─ src   
│  └─ hello_world
│     └─ core.cljs 
├─ cljs.jar 
└─ deps.edn 
Tay answered 29/3, 2020 at 8:2 Comment(0)
B
0

I'm not sure about your specific error, but I created a CLJS sample project that will get you started:

https://github.com/cloojure/cljs-base-project

Just clone the repo to your computer, then you can run the Doo unit tests:

> lein clean; lein doo chrome test once

or use Figwheel:

> lein clean; lein figwheel
Brigettebrigg answered 28/4, 2018 at 19:46 Comment(0)
V
0

Just happened to me in a Linux box, even though I had the correct deps.edn as mentioned in the quickstart.

The solution was to simply remove a previously created .cpcache folder that I had from trying with a different docker image.

Vance answered 7/5, 2022 at 1:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.