【发布时间】:2021-02-22 03:50:43
【问题描述】:
我在尝试使用 shadow-cljs 构建 Clojurescript 项目时遇到此错误。我已经尝试按照here 的描述查找语法错误,但我可以通过单行和单次导入得到相同的错误,尽管并非所有导入都会导致相同的错误。
这样编译:
(ns campfire.core)
(defn init [] (println "ok"))
这不是:
(ns campfire.core
(:require ["bugout" :as b]))
(defn init [] (println "ok"))
上面例子的输出是:
shadow-cljs - config: /home/ru/Projects/campfire/shadow-cljs.edn
shadow-cljs - HTTP server available at http://localhost:3000
shadow-cljs - server version: 2.11.18 running at http://localhost:9630
shadow-cljs - nREPL server started on port 8777
shadow-cljs - watching build :frontend
[:frontend] Configuring build.
[:frontend] Compiling ...
[:frontend] Build failure:
The required JS dependency "readable-stream/writable.js" is not available, it was required by "node_modules/stream-browserify/index.js".
Dependency Trace:
campfire/core.cljs
node_modules/bugout/index.js
node_modules/bs58check/index.js
node_modules/create-hash/browser.js
node_modules/cipher-base/index.js
node_modules/stream-browserify/index.js
Searched for npm packages in:
/home/ru/Projects/campfire/node_modules
See: https://shadow-cljs.github.io/docs/UsersGuide.html#npm-install
package.json
{
"name": "campfire",
"version": "0.0.1",
"private": true,
"scripts": {
"build": "shadow-cljs release frontend"
},
"devDependencies": {
"shadow-cljs": "2.11.18"
},
"dependencies": {
"bugout": "^0.0.10",
"webtorrent": "^0.114.1"
}
}
shadow-cljs.edn
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[]
:dev-http {3000 "public"}
:nrepl {:port 8777}
:builds
{:frontend
{:target :browser
:modules {:main {:init-fn campfire.core/init}}}}}
我看到了类似的构建错误,这些错误通过清除 .shadow-cljs 等并重建得到修复,但似乎没有任何帮助。如果这是显而易见的事情,我对影子很抱歉。有谁知道这里发生了什么?
更新
所以看起来正在发生的事情是stream-browserify 2.0.2 需要 npm 安装在嵌套的 node_modules 文件夹中的 readable stream ^2.0.2。在其他地方 readable-stream 3.6.0 正在安装在顶级 node_modules 中。 Shadow 正在尝试针对 3.6.0 版本的可读流而不是 2.0.2 版本解析 writer.js。
但令人困惑的是,stream-browserify 并不是依赖跟踪中给出的 cipher-base 的依赖,而是 node-libs-browser 的依赖,node-libs-browser 本身就是 shadow-cljs 的依赖。
这可能是阴影中的错误还是预期的行为?
更新 2
我创建了一个示例 repo,它尽可能简单地复制了我所看到的 here。
【问题讨论】: