2017-01-18 8 views
2

私はちょうど公式docsを使用してscalajs-reactを設定しようとしているが、私はこのsbt run実行しようとした際に問題に直面しています実行することができません:scalajs反応するプロジェクト

[info] Fast optimizing C:\temp\scalajs-react\target\scala-2.12\scala-js-tutorial-fastopt.js 
[info] Running org.example.TutorialApp 
[error] module.js:471 
[error]  throw err; 
[error] ^
[error] 
[error] Error: Cannot find module 'react' 
[error]  at Function.Module._resolveFilename (module.js:469:15) 
[error]  at Function.Module._load (module.js:417:25) 
[error]  at Module.require (module.js:497:17) 
[error]  at require (internal/module.js:20:19) 
[error]  at C:\Users\avkar\AppData\Local\Temp\1484704765073-0\react-dom.js:16:24 
[error]  at Object.<anonymous> (C:\Users\avkar\AppData\Local\Temp\1484704765073-0\react-dom.js:40:3) 
[error]  at Module._compile (module.js:570:32) 
[error]  at Object.Module._extensions..js (module.js:579:10) 
[error]  at Module.load (module.js:487:32) 
[error]  at tryModuleLoad (module.js:446:12) 
org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: Node.js 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:684) 
    at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$60$$anonfun$apply$43$$anonfun$apply$44.apply(ScalaJSPluginInternal.scala:771) 
    at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$60$$anonfun$apply$43$$anonfun$apply$44.apply(ScalaJSPluginInternal.scala:765) 
    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 exited with code 1 
[error] Total time: 3 s, completed 18.01.2017 8:59:25 

を、私は私のマシン上でのNode.jsを持っているがしかし、反応モジュールはありませんでした。だから、私はその後、コマンドにnpm install -g [email protected] [email protected]

を使用してbuild.sbtからこれらのモジュールをインストールすることを決めた、私はnpm list -g --depth=0ための次の出力があります。

+-- [email protected] 
+-- [email protected] 
`-- [email protected] 

しかし、それは何も変わりません。まだ同じエラー出力がありますsbt run

これは誰でも分かりますか?

答えて

2

node.jsに直接何もインストールする必要はありません。 npm install -g react...は効果がありません。もしあなたがsbt runを使ってあなたのアプリを走らせたいのであれば、それはReactをインストールする際のSBT設定になるでしょう。

SBTにjsDependencies経由でReactをインストールする方法をscalajs-react docsに示します。他の必要な設定を見つけるには、まだthe Scala.JS tutorialまで読んでおく必要があります。私はsbt runを使っていませんが、チュートリアルによれば、おそらくjsDependencies += RuntimeDOMを追加し、npm install jsdomを実行し、おそらくskip in packageJSDependencies := falseを使用する必要があります。

これはうまくいかない場合、Scala.JSの使用上の問題で、scalajs-reactに固有の問題ではありません。

+0

'sbt run'の代わりに' sbt〜fastOptJS'を試しました。コードが正常にコンパイルされ、HTMLページで結果を確認することができました。ありがとう! –

関連する問題