我只是想使用官方文档设置scalajs-react,但是当我尝试运行它时遇到了一个问题:sbt run
[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,但没有“反应”模块。所以,我决定build.sbt
使用命令安装这些模块npm install -g react@15.3.2 react-dom@15.3.2
之后,我有以下输出npm list -g --depth=0
:
+-- bower@1.8.0
+-- react@15.3.2
`-- react-dom@15.3.2
但是,它没有任何改变。仍然相同的错误输出sbt run
有人知道这是什么吗?