我尝试创建一个非常简单的scala.js应用程序。我正在学习https://www.scala-js.org/doc/tutorial/scalajs-vite.html教程,我想解码一个json。
Circe https://circe.github.io/circe/说circe also provides a parser subproject that provides parsing support for Scala.js, with JVM parsing provided by io.circe.jawn and JavaScript parsing from scalajs.js.JSON.
所以根据https://circe.github.io/circe/parsing.html我有
import io.circe._
import io.circe.parser._
val myValue = parse(event.data.toString)
并具有以下依赖关系
"io.circe" %% "circe-core" % "0.14.5",
"io.circe" %% "circe-parser" % "0.14.5",
这会产生以下错误
[error] Referring to non-existent class io.circe.parser.package$
[error] Cannot access module for non-module io.circe.parser.package$
[error] Referring to non-existent method
io.circe.parser.package$.parse(java.lang.String)scala.util.Either
与仅JVM库的错误类型完全相同:|
1条答案
按热度按时间mwngjboj1#
正如我写的评论中提到的,事实证明这是正确的,Scala. js模块需要在sbt构建定义中使用
%%%
运算符声明,因此您的两个依赖项需要声明如下:你可以阅读更多关于它here on the documentation of Scala.js.