user9714947
user9714947

Reputation:

Running ClojureScript: Unable to locate cljs/main.clj

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.

Upvotes: 8

Views: 2102

Answers (5)

marcelocra
marcelocra

Reputation: 2493

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.

Upvotes: 0

Moe Shaaban
Moe Shaaban

Reputation: 164

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

Upvotes: 2

Asur
Asur

Reputation: 2057

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 

Upvotes: 1

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.

Upvotes: 4

Alan Thompson
Alan Thompson

Reputation: 29958

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

Upvotes: 0

Related Questions