所需的 JS 依赖项“@silvia-odwyer/photon”不可用 -- ClojureScript -- Node.js -- npm -- yarn

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

我正在做示例项目 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/,在按照步骤操作后我收到了这个警告。

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

在执行 'npx shadow-cljs watch client' 或 'yarn shadow-cljs watch client' 之前我试过:

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

文件确实在 node_modules 文件夹中,但它不起作用

我尝试了 'npm cache clean -f' 并再次安装

我尝试删除 node_modules 文件夹和包-lock.jason 文件并重新安装

https://github.com/minimal-xyz/minimal-shadow-cljs-browser

相同的问题

示例项目与包含的依赖项一起工作正常(在安装 Photon 依赖项之前)

这是我安装后的package.json:

{
"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"
}

这是我的影子-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"]}

这里是 main.cljs 文件 requiring/importing 与其他文件的依赖关系相同:

(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

我错过了什么?

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 目前不支持 WebAssembly 捆绑。

不确定为什么会收到一条错误消息,告诉您它不存在。有问题的库包含一个已编译的 .wasm 文件,因此无论如何都无法正常工作。