请在2024 Clojure状态调查中分享您的想法!

欢迎!请参阅关于页面了解更多关于其工作原理的信息。

0投票
ClojureScript

我正在使用shadow-cljs进行开发工作流程,并尝试导入各种npm库。

对于如(loadash, shortid)这样的模块来说效果不错,但是对于诸如ecpaircrawlee这样的模块,我遇到了错误。

对于ecpair

errors in file: .../node_modules/ecpair/src/ecpair.js
{:js-str-offsets [], :js-esm false, :js-imports [], :js-invalid-requires [], :goog-provides [], :js-language "es8", :goog-module nil, :js-warnings [], :resource-name "node_modules/ecpair/src/ecpair.js", :js-requires [], :js-errors [{:line 68, :column 7, :message "'(' expected"}], :goog-requires [], :tag :shadow.build.npm/errors, :uses-global-buffer false}
ExceptionInfo: errors in file: .../node_modules/ecpair/src/ecpair.js
	clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)
	shadow.build.npm/get-file-info* (npm.clj:519)
	shadow.build.npm/get-file-info* (npm.clj:421)
	shadow.build.npm/get-file-info (npm.clj:556)
	shadow.build.npm/get-file-info (npm.clj:553)
	shadow.build.npm/find-resource (npm.clj:645)
	shadow.build.npm/find-resource (npm.clj:605)
	shadow.build.resolve/find-npm-resource (resolve.clj:110)
	shadow.build.resolve/find-npm-resource (resolve.clj:80)
	shadow.build.resolve/fn--11794 (resolve.clj:202)
	shadow.build.resolve/fn--11794 (resolve.clj:183)
	clojure.lang.MultiFn.invoke (MultiFn.java:243)
	shadow.build.resolve/resolve-string-require (resolve.clj:324)
	shadow.build.resolve/resolve-string-require (resolve.clj:307)
	shadow.build.resolve/resolve-require (resolve.clj:491)
	shadow.build.resolve/resolve-require (resolve.clj:484)
	shadow.build.resolve/resolve-deps/fn--11761 (resolve.clj:58)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
	clojure.core/reduce (core.clj:6747)
	clojure.core/reduce (core.clj:6730)
	shadow.cljs.util/reduce-> (util.clj:47)
	shadow.cljs.util/reduce-> (util.clj:46)
	shadow.build.resolve/resolve-deps (resolve.clj:56)
	shadow.build.resolve/resolve-deps (resolve.clj:40)
	shadow.build.resolve/resolve-string-require (resolve.clj:343)
	shadow.build.resolve/resolve-string-require (resolve.clj:307)
	shadow.build.resolve/resolve-require (resolve.clj:491)
	shadow.build.resolve/resolve-require (resolve.clj:484)
	shadow.build.resolve/resolve-deps/fn--11761 (resolve.clj:58)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
	clojure.core/reduce (core.clj:6747)
	clojure.core/reduce (core.clj:6730)
	shadow.cljs.util/reduce-> (util.clj:47)
	shadow.cljs.util/reduce-> (util.clj:46)
	shadow.build.resolve/resolve-deps (resolve.clj:56)
	shadow.build.resolve/resolve-deps (resolve.clj:40)
	shadow.build.resolve/resolve-repl (resolve.clj:528)
	shadow.build.resolve/resolve-repl (resolve.clj:514)
	shadow.cljs.repl/repl-ns (repl.clj:298)
	shadow.cljs.repl/repl-ns (repl.clj:291)
	shadow.cljs.repl/process-read-result (repl.clj:400)
	shadow.cljs.repl/process-read-result (repl.clj:380)
	shadow.cljs.devtools.server.worker.impl/fn--14362 (impl.clj:693)
	shadow.cljs.devtools.server.worker.impl/fn--14362 (impl.clj:657)
	clojure.lang.MultiFn.invoke (MultiFn.java:233)
	shadow.cljs.devtools.server.util/server-thread/fn--14076/fn--14077/fn--14085 (util.clj:294)
	shadow.cljs.devtools.server.util/server-thread/fn--14076/fn--14077 (util.clj:293)
	shadow.cljs.devtools.server.util/server-thread/fn--14076 (util.clj:266)
	java.lang.Thread.run (Thread.java:750)

对于crawlee

errors in file: .../node_modules/@crawlee/core/errors.js
{:js-str-offsets [], :js-esm false, :js-imports [], :js-invalid-requires [], :goog-provides [], :js-language "es3", :goog-module nil, :js-warnings [], :resource-name "node_modules/@crawlee/core/errors.js", :js-requires [], :js-errors [{:line 27, :column 24, :message "primary expression expected"}], :goog-requires [], :tag :shadow.build.npm/errors, :uses-global-buffer false}
ExceptionInfo: errors in file: .../node_modules/@crawlee/core/errors.js
	clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)
	shadow.build.npm/get-file-info* (npm.clj:519)
	shadow.build.npm/get-file-info* (npm.clj:421)
	shadow.build.npm/get-file-info (npm.clj:556)
	shadow.build.npm/get-file-info (npm.clj:553)
	shadow.build.npm/find-resource (npm.clj:645)
	shadow.build.npm/find-resource (npm.clj:605)
	shadow.build.resolve/find-npm-resource (resolve.clj:110)
	shadow.build.resolve/find-npm-resource (resolve.clj:80)
	shadow.build.resolve/fn--11794 (resolve.clj:202)
	shadow.build.resolve/fn--11794 (resolve.clj:183)
	clojure.lang.MultiFn.invoke (MultiFn.java:243)
	shadow.build.resolve/resolve-string-require (resolve.clj:324)
	shadow.build.resolve/resolve-string-require (resolve.clj:307)
	shadow.build.resolve/resolve-require (resolve.clj:491)
	shadow.build.resolve/resolve-require (resolve.clj:484)
	shadow.build.resolve/resolve-deps/fn--11761 (resolve.clj:58)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
	clojure.core/reduce (core.clj:6747)
	clojure.core/reduce (core.clj:6730)
	shadow.cljs.util/reduce-> (util.clj:47)
	shadow.cljs.util/reduce-> (util.clj:46)
	shadow.build.resolve/resolve-deps (resolve.clj:56)
	shadow.build.resolve/resolve-deps (resolve.clj:40)
	shadow.build.resolve/resolve-string-require (resolve.clj:343)
	shadow.build.resolve/resolve-string-require (resolve.clj:307)
	shadow.build.resolve/resolve-require (resolve.clj:491)
	shadow.build.resolve/resolve-require (resolve.clj:484)
	shadow.build.resolve/resolve-deps/fn--11761 (resolve.clj:58)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
	clojure.core/reduce (core.clj:6747)
	clojure.core/reduce (core.clj:6730)
	shadow.cljs.util/reduce-> (util.clj:47)
	shadow.cljs.util/reduce-> (util.clj:46)
	shadow.build.resolve/resolve-deps (resolve.clj:56)
	shadow.build.resolve/resolve-deps (resolve.clj:40)
	shadow.build.resolve/resolve-string-require (resolve.clj:343)
	shadow.build.resolve/resolve-string-require (resolve.clj:307)
	shadow.build.resolve/resolve-require (resolve.clj:491)
	shadow.build.resolve/resolve-require (resolve.clj:484)
	shadow.build.resolve/resolve-deps/fn--11761 (resolve.clj:58)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
	clojure.core/reduce (core.clj:6747)
	clojure.core/reduce (core.clj:6730)
	shadow.cljs.util/reduce-> (util.clj:47)
	shadow.cljs.util/reduce-> (util.clj:46)
	shadow.build.resolve/resolve-deps (resolve.clj:56)
	shadow.build.resolve/resolve-deps (resolve.clj:40)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:481)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:433)
	shadow.build.resolve/resolve-require (resolve.clj:488)
	shadow.build.resolve/resolve-require (resolve.clj:484)
	shadow.build.resolve/resolve-entry (resolve.clj:498)
	shadow.build.resolve/resolve-entry (resolve.clj:497)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
	clojure.core/reduce (core.clj:6747)
	clojure.core/reduce (core.clj:6730)
	shadow.cljs.util/reduce-> (util.clj:47)
	shadow.cljs.util/reduce-> (util.clj:46)
	shadow.build.resolve/resolve-entries (resolve.clj:509)
	shadow.build.resolve/resolve-entries (resolve.clj:500)
	shadow.build.modules/analyze-module/fn--12569 (modules.clj:243)
	shadow.build.modules/analyze-module (modules.clj:239)
	shadow.build.modules/analyze-module (modules.clj:228)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
	clojure.core/reduce (core.clj:6747)
	clojure.core/reduce (core.clj:6730)
	shadow.build.modules/analyze-modules (modules.clj:259)
	shadow.build.modules/analyze-modules (modules.clj:258)
	shadow.build.modules/analyze (modules.clj:313)
	shadow.build.modules/analyze (modules.clj:304)
	shadow.build/resolve (build.clj:346)
	shadow.build/resolve (build.clj:340)
	shadow.build/compile (build.clj:354)
	shadow.build/compile (build.clj:348)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:251)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:237)
	shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:779)
	shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:742)

我猜测这可能与shadow-cljs解释这些库的方式有关,但我不确定如何配置shadow-cljs.edn才能达到目的。

1 个回答

0投票

在跨发时,请将问题链接在一起,以便不同的人不会尝试解决同一个问题。

我的回答在这里:https://clojureverse.org/t/cannot-import-certain-npm-modules-with-shadow-cljs/9456/2?u=p-himik

...