Fork me on GitHub
#shadow-cljs
<
2022-10-15
>
sheluchin10:10:43

Installing https://fomantic-ui.com/introduction/getting-started.html#installing-via-npm using NPM, it ends up with the pre-compiled css and js files inside node_modules/fomantic-ui/dist/. If I want to include them in my html, what is the right way to refer to their location?

sheluchin10:10:21

I suppose I can just move the files to some location in my path like "resources/public/fomantic-ui/", but if anyone knows of a better way to make these files accessible please let me know.

Lone Ranger13:10:03

I would write a JavaScript file that imports and requires the compiled CSS and then include that in your code

sheluchin13:10:32

@U3BALC2HH so I install with NPM and the compiled CSS+JS files end up in node_modules/.... My public HTML files do not have access to the files in node_modules (I think..?)... sorry, I'm confused, could you elaborate please?

Lone Ranger14:10:15

nope! Here's an example:

// <projectRoot>/src/js/index.js

import 'draft-js/dist/Draft.css';
(ns myproject.core
  (:require "/src/js/index.js"))

Lone Ranger14:10:49

so in your case it would probably be something like fomantic-ui/dist/something.css

Lone Ranger14:10:42

(keep in mind this won't work well if you are trying to distribute the code as a library, but it would work if you're making an npm module or some kind of app with no downstream consumers)

sheluchin13:10:14

@U3BALC2HH thank you for the example. I will try that out. Is there any advantage to doing this instead of just moving the dist files after installing?

pez11:10:23

I just made a testing project where I only use the browser-repl and node-repl, so no builds. shadow-cljs.edn looks like so

{}
Starting this with
npx shadow-cljs browser-repl
works fine. But with
npx shadow-cljs node-repl
I get:
% npx shadow-cljs node-repl    
------------------------------------------------------------------------------

   WARNING: shadow-cljs not installed in project.
   See 

------------------------------------------------------------------------------
shadow-cljs - config: /Users/pez/.config/joyride/shadow-cljs.edn
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
[2022-10-15 13:43:16.382 - WARNING] TCP Port 9630 in use.
[2022-10-15 13:43:16.385 - WARNING] TCP Port 9631 in use.
shadow-cljs - server version: 2.20.5 running at 
shadow-cljs - nREPL server started on port 57047
cljs.user=> SHADOW import error /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js
[stdin]:66
    throw e;
    ^

Error: Cannot find module 'ws'
Require stack:
- /Users/pez/.config/joyride/[stdin]
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1022:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js:3:28
    at global.SHADOW_IMPORT ([stdin]:63:44)
    at [stdin]:1535:1
    at [stdin]:1579:3
    at Script.runInThisContext (node:vm:129:12)
    at Object.runInThisContext (node:vm:313:38)
[2022-10-15 13:43:18.498 - INFO] :shadow.cljs.devtools.server.repl-impl/node-repl-exit - {:code 1}
SHADOW import error /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js
[stdin]:66
    throw e;
    ^
And a lot of those. Then a lot of:
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> SHADOW import error /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js
Failed to read: java.io.IOException: Input/output error
cljs.user=> [stdin]:66
    throw e;
    ^

Error: Cannot find module 'ws'
Require stack:
- /Users/pez/.config/joyride/[stdin]
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1022:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js:3:28
    at global.SHADOW_IMPORT ([stdin]:63:44)
    at [stdin]:1535:1
    at [stdin]:1579:3
    at Script.runInThisContext (node:vm:129:12)
    at Object.runInThisContext (node:vm:313:38)
Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
Am I missing some minimal config for this to work with node-repl?

pez12:10:40

Adding shadow-cljs to my node project fixed this. Don't know if it was because npx otherwise runs some old version...

thheller16:10:09

npx otherwise runs a globally installed version. you need to project install, so it provides the ws dependency among others. thats why there is the WARNING: shadow-cljs not installed in project. warning

pez16:10:03

Thanks! I have for very long wondered about that warning. 😃 Never run into problems skipping it. Most often I have not skipped it, though, so maybe that has to do with it. It was the warning that got me to try to fix my problem with the install, though, so it did its work. Maybe add problems might ensue to the message for thick-heads like me.

pez12:10:40
replied to a thread:I just made a testing project where I only use the browser-repl and node-repl, so no builds. `shadow-cljs.edn` looks like so {} Starting this with npx shadow-cljs browser-repl works fine. But with npx shadow-cljs node-repl I get: % npx shadow-cljs node-repl ------------------------------------------------------------------------------ WARNING: shadow-cljs not installed in project. See <https://shadow-cljs.github.io/docs/UsersGuide.html#project-install> ------------------------------------------------------------------------------ shadow-cljs - config: /Users/pez/.config/joyride/shadow-cljs.edn shadow-cljs - updating dependencies shadow-cljs - dependencies updated [2022-10-15 13:43:16.382 - WARNING] TCP Port 9630 in use. [2022-10-15 13:43:16.385 - WARNING] TCP Port 9631 in use. shadow-cljs - server version: 2.20.5 running at <http://localhost:9632> shadow-cljs - nREPL server started on port 57047 cljs.user=&gt; SHADOW import error /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js [stdin]:66 throw e; ^ Error: Cannot find module 'ws' Require stack: - /Users/pez/.config/joyride/[stdin] at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15) at Function.Module._load (node:internal/modules/cjs/loader:804:27) at Module.require (node:internal/modules/cjs/loader:1022:19) at require (node:internal/modules/cjs/helpers:102:18) at /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js:3:28 at global.SHADOW_IMPORT ([stdin]:63:44) at [stdin]:1535:1 at [stdin]:1579:3 at Script.runInThisContext (node:vm:129:12) at Object.runInThisContext (node:vm:313:38) [2022-10-15 13:43:18.498 - INFO] :shadow.cljs.devtools.server.repl-impl/node-repl-exit - {:code 1} SHADOW import error /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js [stdin]:66 throw e; ^ And a lot of those. Then a lot of: cljs.user=&gt; Failed to read: java.io.IOException: Input/output error cljs.user=&gt; Failed to read: java.io.IOException: Input/output error cljs.user=&gt; Failed to read: java.io.IOException: Input/output error cljs.user=&gt; Failed to read: java.io.IOException: Input/output error cljs.user=&gt; Failed to read: java.io.IOException: Input/output error cljs.user=&gt; Failed to read: java.io.IOException: Input/output error cljs.user=&gt; Failed to read: java.io.IOException: Input/output error cljs.user=&gt; SHADOW import error /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js Failed to read: java.io.IOException: Input/output error cljs.user=&gt; [stdin]:66 throw e; ^ Error: Cannot find module 'ws' Require stack: - /Users/pez/.config/joyride/[stdin] at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15) at Function.Module._load (node:internal/modules/cjs/loader:804:27) at Module.require (node:internal/modules/cjs/loader:1022:19) at require (node:internal/modules/cjs/helpers:102:18) at /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js:3:28 at global.SHADOW_IMPORT ([stdin]:63:44) at [stdin]:1535:1 at [stdin]:1579:3 at Script.runInThisContext (node:vm:129:12) at Object.runInThisContext (node:vm:313:38) Failed to read: java.io.IOException: Input/output error cljs.user=&gt; Failed to read: java.io.IOException: Input/output error cljs.user=&gt; Failed to read: java.io.IOException: Input/output error cljs.user=&gt; Failed to read: java.io.IOException: Input/output error cljs.user=&gt; Failed to read: java.io.IOException: Input/output error Am I missing some minimal config for this to work with node-repl?

Adding shadow-cljs to my node project fixed this. Don't know if it was because npx otherwise runs some old version...

sheluchin10:10:21

I suppose I can just move the files to some location in my path like "resources/public/fomantic-ui/", but if anyone knows of a better way to make these files accessible please let me know.