简体   繁体   中英

Scala.js can not be run in a forked JVM

I am trying to create an SPA with Scala.js so I following the tutorial from here: http://www.scala-js.org/tutorial/basic/

I have added addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.7") to plugins.sbt and enablePlugins(ScalaJSPlugin) to build.sbt .

However, I am getting this error:

Error:Error while importing SBT project:<br/>...<br/><pre>[info]    [SUCCESSFUL ] args4j#args4j;2.0.16!args4j.jar (92ms)
[info] downloading https://repo1.maven.org/maven2/org/webjars/envjs/1.2/envjs-1.2.jar ...
[info]  [SUCCESSFUL ] org.webjars#envjs;1.2!envjs.jar (179ms)
[info] Done updating.
java.lang.RuntimeException: Scala.js cannot be run in a forked JVM
    at scala.sys.package$.error(package.scala:27)
    at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$43.apply(ScalaJSPluginInternal.scala:551)
    at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$43.apply(ScalaJSPluginInternal.scala:549)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.EvaluateSettings$MixedNode.evaluate0(INode.scala:175)
    at sbt.EvaluateSettings$INode.evaluate(INode.scala:135)
    at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$submitEvaluate$1.apply$mcV$sp(INode.scala:69)
    at sbt.EvaluateSettings.sbt$EvaluateSettings$$run0(INode.scala:78)
    at sbt.EvaluateSettings$$anon$3.run(INode.scala:74)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[error] Scala.js cannot be run in a forked JVM
[error] Use 'last' for the full log.

Why doesn't Scala.js work with JVM?

This seems to be a known issue

you should:

That's because you mix both JVM stuff (Play) and JS stuff in the same sbt project. You cannot do that. You need separate sbt projects (in the same build). See https://github.com/vmunier/play-with-scalajs-example for how to use Scala.js with Play!.

this an example

This normally happens due to conflicts with other sbt plugins which include jvm libraries in the same project as scalajs. Without seeing the rest of your build.sbt and plugins.sbt its impossible to say exactly what is causing the conflicts.

Assuming you are trying to integrate it with play, here is an example project which should help you get started:

https://github.com/vmunier/play-with-scalajs-example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM