如何运行 Scala .js 1.3.0 教程 - 第 2 部分?

Eri*_*luk 1 scala.js

将项目移动到 C: 上的本地文件系统后,现在我得到了

sbt:Scala.js Tutorial> run
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Compiling 1 Scala source to C:\Users\ERIC\Documents\git\scalajs-tutorial\target\scala-2.13\classes ...
[info] Fast optimizing C:\Users\ERIC\Documents\git\scalajs-tutorial\target\scala-2.13\scala-js-tutorial-fastopt
[info] Running tutorial.webapp.TutorialApp. Hit any key to interrupt.
internal/modules/cjs/loader.js:834
  throw err;
  ^

Error: Cannot find module 'jsdom'
Require stack:
- C:\Users\ERIC\Documents\git\scalajs-tutorial\[stdin]
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:903:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at codeWithJSDOMContext.js:3:15
    at codeWithJSDOMContext.js:52:3
    at Script.runInThisContext (vm.js:120:18)
    at Object.runInThisContext (vm.js:309:38)
    at [stdin]:2:29
    at Script.runInThisContext (vm.js:120:18) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'C:\\Users\\ERIC\\Documents\\git\\scalajs-tutorial\\[stdin]' ]
}
[error] org.scalajs.jsenv.ExternalJSRun$NonZeroExitException: exited with code 1
[error]         at org.scalajs.jsenv.ExternalJSRun$$anon$1.run(ExternalJSRun.scala:186)
[error] stack trace is suppressed; run last Compile / run for the full output
[error] (Compile / run) org.scalajs.jsenv.ExternalJSRun$NonZeroExitException: exited with code 1
[error] Total time: 6 s, completed Oct. 16, 2020, 9:53:33 a.m.
Run Code Online (Sandbox Code Playgroud)

sbt:Scala.js Tutorial> evicted
[warn] Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[warn]  * org.scala-js:scalajs-library_2.13:1.3.0 is selected over 1.0.0
[warn]      +- scala-js-tutorial:scala-js-tutorial_sjs1_2.13:0.1.0-SNAPSHOT (depends on 1.3.0)
[warn]      +- org.scala-js:scalajs-dom_sjs1_2.13:1.1.0           (depends on 1.0.0)
[success] Total time: 0 s, completed Oct. 16, 2020, 10:18:13 a.m.
Run Code Online (Sandbox Code Playgroud)

Scala.js 1.3.0 是否已使用 ( https://github.com/scala-js/scalajs-tutorial )上的教程进行了测试?

Nik*_*ita 5

它有点隐藏,但从存储库链接的教程提到您需要单独安装 jsdom:

这将使用 jsdom 库来模拟 Node.js 中的 DOM。请注意,您需要使用单独安装

$ npm install jsdom
Run Code Online (Sandbox Code Playgroud)

重新加载后即可调用run成功