Search code examples
npm-installclojurescriptpackage.jsonednclojurescript-javascript-interop

The required JS dependency "@silvia-odwyer/photon" is not available -- ClojureScript -- Node.js -- npm -- yarn


I am doing the example project https://github.com/minimal-xyz/minimal-shadow-cljs-importing-npm to later add Photon dependency https://silvia-odwyer.github.io/photon/guide/using-photon-web/ and after following the steps I get this warning.

PS C:\Users\usuario\desktop\clojure\minimal-shadow-cljs-browser> yarn
shadow-cljs watch app
yarn run v1.22.10
$ C:\Users\usuario\desktop\clojure\minimal-shadow-cljs-browser\node_mo
dules\.bin\shadow-cljs watch app
shadow-cljs - config: C:\Users\usuario\desktop\clojure\minimal-shadow-
cljs-browser\shadow-cljs.edn
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - HTTP server available at http://localhost:8080
shadow-cljs - server version: 2.11.5 running at http://localhost:9630
shadow-cljs - nREPL server started on port 49569
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
The required JS dependency "@silvia-odwyer/photon" is not available, i
t was required by "app/main.cljs".

Dependency Trace:
        app/main.cljs

Searched for npm packages in:
        C:\Users\usuario\desktop\clojure\minimal-shadow-cljs-browser\n
ode_modules

See: https://shadow-cljs.github.io/docs/UsersGuide.html#npm-install

Before execute 'npx shadow-cljs watch client' or 'yarn shadow-cljs watch client' I tried with:

npm install --save @silvia-odwyer/photon
npm install @silvia-odwyer/photon
yarn add @silvia-odwyer/photon

and the files are in node_modules folder indeed, but it doesn't work

I tried 'npm cache clean -f' and installing again

I tried deleting node_modules folder and package-lock.jason file and installing again

The same issue with https://github.com/minimal-xyz/minimal-shadow-cljs-browser

The example projects work fine with the included dependencies (before installing Photon dependency)

Here is my package.json after installing:

{
"scripts": {
"html": "mkdir -p target/; cp entry/index.html target/"
},
"dependencies": {
"@silvia-odwyer/photon": "^0.2.0",
"dayjs": "^1.7.7",
"lodash": "^4.17.19",
"shortid": "^2.2.13"
},
"devDependencies": {
"shadow-cljs": "^2.6.23"
},
"name": "minimal-shadow-cljs-importing-npm",
"description": "",
"version": "0.1.0",
"main": "index.js",
"author": "",
"license": "MIT"
}

Here is my shadow-cljs.edn:

{:source-paths ["src"]
:builds {:client {:output-dir "target/"
:asset-path "./"
:target :browser
:modules {:client {:init-fn app.main/main!}}
:devtools {:after-load app.main/reload!
:http-root "target"
:http-port 8080}}}
:jvm-opts ["-Xmx1024m"]}

And heres is the main.cljs file requiring/importing the dependency the same as the others:

(ns app.main
(:require ["dayjs" :as dayjs]
["shortid" :as shortid]
["lodash" :as lodash]
["lodash" :refer [isString]]
["@silvia-odwyer/photon" :as sop]))
PS C:\Users\usuario\desktop\clojure\minimal-shadow-cljs-browser> node -v
v12.19.0
PS C:\Users\usuario\desktop\clojure\minimal-shadow-cljs-browser> npm -v
6.14.8

I'm missing something?


Solution

  • Photon is a high-performance image processing library, written in Rust and compilable to WebAssembly, which can be used both natively and on the web.

    shadow-cljs does not support WebAssembly bundling at this point.

    Not sure why you are getting an error telling you that it doesn't exist. The library in question contains a compiled .wasm file and as such won't work properly anyways though.