1

我正在做示例项目https://github.com/minimal-xyz/minimal-shadow-cljs-importing-npm以稍后添加 Photon 依赖项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 文件夹和 package-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"
}

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

这里是 main.cljs 文件,需要/导入与其他相同的依赖项:

(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

我错过了什么?

4

1 回答 1

1

Photon 是一个高性能的图像处理库,用 Rust 编写,可编译为 WebAssembly,既可以在本地使用,也可以在 Web 上使用。

shadow-cljs 目前不支持 WebAssembly 捆绑。

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

于 2020-10-10T14:44:46.073 回答