我正在尝试遵循 ScalaJS Book 教程。基于他们的 build.sbt 示例https://github.com/ochrons/scalajs-spa-tutorial/blob/master/build.sbt
我创建了以下 build.sbt
lazy val client = (project in file("client"))
.settings(
name := "client",
version := "1.0.0",
scalaVersion := "2.12.4",
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "0.9.4",
"com.lihaoyi" %%% "scalatags" % "0.6.7",
"com.vmunier" %% "scalajs-scripts" % "1.1.1",
"org.webjars" % "font-awesome" % "5.0.6" % Provided,
"org.webjars" % "bootstrap" % "4.0.0" % Provided,
"com.lihaoyi" %% "utest" % "0.6.3" % Test
),
jsDependencies ++= Seq(
"org.webjars.bower" % "react" % "16.1.0" / "react-with-addons.js" minified "react-with-addons.min.js" commonJSName "React",
"org.webjars.bower" % "react" % "16.1.0" / "react-dom.js" minified "react-dom.min.js" dependsOn "react-with-addons.js" commonJSName "ReactDOM",
"org.webjars" % "jquery" % "3.3.1" / "jquery.js" minified "jquery.min.js",
"org.webjars" % "bootstrap" % "4.0.0" / "bootstrap.js" minified "bootstrap.min.js" dependsOn "jquery.js",
"org.webjars" % "chartjs" % "2.7.0" / "Chart.js" minified "Chart.min.js",
"org.webjars" % "log4javascript" % "1.4.13" / "js/log4javascript_uncompressed.js" minified "js/log4javascript.js"
),
skip in packageJSDependencies := false,
scalaJSUseMainModuleInitializer := true,
scalaJSUseMainModuleInitializer in Test := false,
testFrameworks += new TestFramework("utest.runner.Framework")
).enablePlugins(ScalaJSPlugin).dependsOn(SharedJS)
但是当我这样做时,sbt ~fastOptJS
我得到一个错误
[error] org.scalajs.core.tools.jsdep.JSLibResolveException: Some references to JS libraries could not be resolved:
[error] - Missing JS library: react-dom.js
[error] originating from: client:compile
[error] - Missing JS library: react-with-addons.js
[error] originating from: client:compile
[error]
[error] at org.scalajs.core.tools.jsdep.DependencyResolver$.resolveAllResourceNames(DependencyResolver.scala:84)
[error] at org.scalajs.core.tools.jsdep.DependencyResolver$.resolveDependencies(DependencyResolver.scala:25)
[error] at org.scalajs.sbtplugin.ScalaJSPluginInternal$.$anonfun$scalaJSConfigSettings$46(ScalaJSPluginInternal.scala:671)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:39)
[error] at sbt.std.Transform$$anon$4.work(System.scala:66)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:262)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error] at sbt.Execute.work(Execute.scala:271)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:262)
[error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:174)
[error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:36)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error] (client / Compile / resolvedJSDependencies) org.scalajs.core.tools.jsdep.JSLibResolveException: Some referencesto JS libraries could not be resolved:
[error] - Missing JS library: react-dom.js
[error] originating from: client:compile
[error] - Missing JS library: react-with-addons.js
[error] originating from: client:compile
[error] Total time: 3 s, completed Feb 10, 2018 9:02:20 PM