basic Scala.js tutorialをビルドしようとしていますが、この奇妙なエラーが発生しています。TypeError:jsdom.createVirtualConsoleは関数ではありません
あり、チュートリアルのようにセットアッププロジェクトと大差ありませんが、念のためにここに私のbuild.sbtです:
enablePlugins(ScalaJSPlugin)
scalaVersion := "2.12.1"
name := "algorithms1_4_34"
version := "1.0"
libraryDependencies ++= Seq("org.scalatest" % "scalatest_2.12" % "3.0.1" % "test",
"org.scalacheck" %% "scalacheck" % "1.13.4" % "test",
"org.scala-js" % "scalajs-dom_sjs0.6_2.12" % "0.9.1",
"be.doeraene" %%% "scalajs-jquery" % "0.9.1")
// This is an application with a main method
scalaJSUseMainModuleInitializer := true
skip in packageJSDependencies := false
jsDependencies +=
"org.webjars" % "jquery" % "2.1.4"/"2.1.4/jquery.js"
jsDependencies += RuntimeDOM
...とJSAppファイル:
package ca.vgorcinschi.algorithms1_4_34
import scala.scalajs.js.JSApp
import org.scalajs.jquery.jQuery
object HotAndColdJS extends JSApp{
def main(): Unit = {
jQuery(()=>setupUI())
}
def addClickedMessage():Unit ={
jQuery("body").append("<p>You clicked the button!</p>")
}
def setupUI():Unit = {
//click envokes an event handler
jQuery("#click-me-button").click(()=> addClickedMessage())
jQuery("body").append("<p>Hello World!</p>")
}
}
私は問題なく、compile
、fastOptJS
、reload
およびとeclipse
(私はeclipsePluginを使用しています)コマンドを実行できます。唯一の問題はrun
コマンドです。公平にするために、私はチュートリアルの流れに何かを追加しましたが、アプリケーションのルートからこのコマンド(npm install jsdom
)を実行すると、run
(npm WARN enoent ENOENT
)の失敗につながるからです。
npm init
npm install
npm install jsdom
をそして、私は今の私場所です。これに続いてアドバイスhereとして私が走りました。誰もこれを私の手を与えることができれば、私は感謝
> run
[info] Running ca.vgorcinschi.algorithms1_4_34.HotAndColdJS
[error] [stdin]:40
[error] virtualConsole: jsdom.createVirtualConsole().sendTo(console),
[error] ^
[error]
[error] TypeError: jsdom.createVirtualConsole is not a function
[error] at [stdin]:40:27
[error] at [stdin]:61:3
[error] at ContextifyScript.Script.runInThisContext (vm.js:23:33)
[error] at Object.runInThisContext (vm.js:95:38)
[error] at Object.<anonymous> ([stdin]-wrapper:6:22)
[error] at Module._compile (module.js:571:32)
[error] at evalScript (bootstrap_node.js:391:27)
[error] at Socket.<anonymous> (bootstrap_node.js:188:13)
[error] at emitNone (events.js:91:20)
[error] at Socket.emit (events.js:188:7)
org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: Node.js with JSDOM exited with code 1
at org.scalajs.jsenv.ExternalJSEnv$AbstractExtRunner.waitForVM(ExternalJSEnv.scala:107)
at org.scalajs.jsenv.ExternalJSEnv$ExtRunner.run(ExternalJSEnv.scala:156)
at org.scalajs.sbtplugin.ScalaJSPluginInternal$.org$scalajs$sbtplugin$ScalaJSPluginInternal$$jsRun(ScalaJSPluginInternal.scala:697)
at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$73$$anonfun$apply$48$$anonfun$apply$49.apply(ScalaJSPluginInternal.scala:814)
at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$73$$anonfun$apply$48$$anonfun$apply$49.apply(ScalaJSPluginInternal.scala:808)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: Node.js with JSDOM exited with code 1
[error] Total time: 4 s, completed 23-May-2017 9:24:20 PM
:これはrun
でアプリを実行しているときに私が取得エラーです。
Scala.jsのどのバージョンを使用していますか? jsdom v10がリリースされたので、Scala.js 0.6.16が必要です。古いバージョンはjsdom v10で動作しません。 – sjrd
ありがとうございます。それかもしれない。私のScala.jsは0.6.15です。古いバージョンのjsdomをインストールする方法はありませんか? – vasigorc
私はScala.jsを0.6.16にアップグレードしました。 Thanks @ sjrdご希望の場合は、あなたのコメントを回答にコピーすることができます。私はそれを正しいものとしてマークすることができます。他人を助けることができるかもしれない。 – vasigorc