This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-25
Channels
- # announcements (2)
- # beginners (30)
- # biff (12)
- # calva (2)
- # cider (62)
- # clerk (18)
- # clj-commons (20)
- # clojure (9)
- # clojure-europe (6)
- # clojure-switzerland (1)
- # core-logic (6)
- # datomic (4)
- # events (3)
- # fulcro (1)
- # membrane (15)
- # off-topic (16)
- # portal (24)
- # practicalli (2)
- # releases (1)
- # rewrite-clj (45)
- # shadow-cljs (14)
- # tools-build (1)
- # xtdb (4)
linux
where do global npm packages get installed on linux? basically, we can either fix the PATH or we can just (setq cider-shadow-cljs-command "/full/path/to/shadow-cljs")
I have a .npm
directory, but it looks like _npx
is just weirdly named directories...
Also nil
The path to shadow-cljs? Will it be a binary?
On my machine it seems to be a script
% file $(which shadow-cljs)
/opt/local/bin/shadow-cljs: a /usr/bin/env node script text executable, ASCII text
ok I think I got it
cool; now just make sure executable-find
returns a non-nil value with the path, and if it does, try using it as your cider-shadow-cljs-command
> error in process sentinel: Could not start nREPL server: /usr/bin/env: ‘node’: No such file or directory
I'll try a fighweel-main project after all
out of curiosity, do you have the exec-path-from-shell
package installed? if not, then that may help you with PATH issues with Emacs
Ah great library. I added it to my config file, thanks!
I was able to run shadow-cljs via CIDER with a lein reagent
template. It works well, so I guess lein-figwheel
is indeed a potential source for my issue 😞
I just spent the day migrating to shadow-cljs
, realizing it's way too reliant on npm
, then migrating to figwheel-main
... and I have the same issue!

Wouldn't I need to manually install most/all of my cljsjs dependencies?
> The shadow-cljsjs
library only provides the shim files. You’ll still need to npm install
the actual packages yourself.
most libraries nowadays have been updated to properly declare :npm-deps
, so they'll be installed automatically. although you still want to keep track of them
:thinking_face:
So if react wasn't working, it was probably only because I didn't have shadow-cljsjs
?
For a one-time, of course not. But in the grand scheme of things, it's adding one more build tool. In 4 years when I'll come back to the project, I will curse my past self 😕
npm creates a package-lock.json
, which ensures you get exactly the same dependencies in 4 years
Sure, but I mean having to call npm install
I know it's small, but I'd rather avoid having it if possible. Adding more dev tools is always painful in the long run.
imo it’s much better than dealing with the (often errorneous) externs that ship with CLJSJS packages then debugging issues that only manifest in release builds
But at least I have the shadow-cljs migration in a branch, so I can try to see if I had something else breaking things
i used to find shadow-cljs super complicated when I was coming to cljs from clojure, but once it clicked, i never want to go back to other build tools… having to npm ci
on my machine or in a CI build is not a big deal at all IMO… if anything, I’d say leiningen is the extra build tool that can go away (for a cljs frontend at least) 😄
anecdotally, cljs projects have the most friction or ceremony to get running when people decide to mix them in with lein or deps.edn instead of just using shadow-cljs from npm directly
I'll try tomorrow morning then I can't be far from getting it to compile 😅
if your project has managed to survive without needing to pull in any npm library that is not react, then I’d say there is a very good chance you should be migrating over to shadow-cljs
i know this is another anecdote, but ive seen a cljs codebase old enough to migrate from Om to Reagent then Prismatic Schema to clojure.spec then lein-cljsbuild to figwheel and so on…. and migrating it over to shadow-cljs wasn’t a big hassle, it actually simplified the steps needed to set up a development environment on the app’s frontend
of course not all cljs libraries out there are perfect… devcards has hard dependencies on cljsjs packages but you can shim them out and use the npm versions directly, but the only CLJS library that has given me issues with shadow-cljs has been, well, devcards. Everything else didn’t need me to put much effort or thought to add to my project.
Very interesting; my project is roughly the same age then
I do have a 'few' cljsjs deps
[cljsjs/codemirror "5.44.0-1"]
[cljsjs/filesaverjs "1.3.3-0"]
[cljsjs/moment "2.24.0-0"]
[cljsjs/react-beautiful-dnd "10.0.4-0"]
[cljsjs/react-grid-layout "0.17.1-0"]
[cljsjs/react-transition-group "1.2.0-0"]
[cljsjs/react-virtualized "9.21.2-1"]
[cljsjs/resize-observer-polyfill "1.4.2-0"]
all of those should be simple to install from npm, the only change needed to your codebase is that (require '[cljsjs.moment :as moment])
becomes simply (require '["moment" :as moment])
the good news is that you can just make shim namespaces so that you can “require” cljsjs.moment but under the hood its the npm version — this will greatly assist in migrating your codebase over
of course, I understand your original issue is mostly CIDER REPL suddenly changing namespace to cljs.user
every time a form is submitted in a separate namespace
and while migrating to shadow-cljs is a non-trivial task — i think the benefits outweigh the costs here, assuming that CIDER plays nicely with shadow-cljs on your end (i.e. you can eval things without this namespace issue)
Yeah it's far from my initial issue, but hey, if it can solve it AND prevent some painful migration later on 🤷
By shimming namespaces, do you mean I should do (ns cljsjs.moment ...)
, or is that something shadow-cljsjs does automatically?
I believe there is a shadow-cljsjs
library that can automagically generate shims for you, but I’ve never used it. The shims are very simple to set up anyway
I don't recommend creating cljsjs namespaces. they only exist to help with libraries that use them
the use case here is to prevent having to refactor an entire project beforehand, basically try getting the npm package to work with the codebase, then refactor so that the shims can be safely deleted
but i guess rewrite-clj
and related tools should help automate the process of changing the require
s across files
Alright, I try again in the morning. Thanks to you both 🙏
It keeps returning to cljs.user
my.ns> (+ 1 1)
2
cljs.user>
possible figwheel issue then. what youve describe basically never happens to me with shadow-cljs
the only npm thing shadow-cljs needs is a websocket library; if invoking from lein then you will need an nrepl middleware for cider, but otherwise I dont see much reliance on npm
is it possible to run a function that returns a promise from the cider repl and have it inspect the value inside the promise instead of the promise itself? I know i can manually def
the result from within a then
and then evaluate that separately, but i'm trying to get my regular data-exploration workflow to work with promises. (i'm using nbb
in case that matters)