In scala.js, what are the possible causes of "Error: Cannot find module 'jsdom'"?
In scala.js, what are the possible causes of "Error: Cannot find module 'jsdom'"?
我正在尝试编译 运行 scala.js 基础教程,网址为:
https://github.com/scala-js/scalajs-tutorial
当我通过 sbt run
执行主 class 时,我收到以下错误消息:
$ sbt run
[info] welcome to sbt 1.6.2 (Private Build Java 1.8.0_312)
[info] loading global plugins from /home/xxx/.sbt/1.0/plugins
[info] loading settings for project scalajs-tutorial-build from plugins.sbt ...
[info] loading project definition from /home/xxx/git-release/scalajs-tutorial/project
[info] loading settings for project scalajs-tutorial from build.sbt ...
[info] set current project to Scala.js Tutorial (in build file:/home/xxx/git-release/scalajs-tutorial/)
[info] Running tutorial.webapp.TutorialApp.
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'jsdom'
Require stack:
- /home/xxx/git-release/scalajs-tutorial/[stdin]
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at codeWithJSDOMContext.js:3:15
at codeWithJSDOMContext.js:52:3
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:305:38)
at [stdin]:2:29
at Script.runInThisContext (node:vm:129:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/xxx/git-release/scalajs-tutorial/[stdin]' ]
}
[error] org.scalajs.jsenv.ExternalJSRun$NonZeroExitException: exited with code 1
[error] at org.scalajs.jsenv.ExternalJSRun$$anon.run(ExternalJSRun.scala:195)
[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: 3 s, completed 28-Feb-2022 12:57:35 AM
这是什么原因造成的,我该如何解决?
问题很可能是您没有为您的项目安装 jsdom
。您可以通过 运行
$ npm install jsdom
在你启动 sbt 的目录中。
我正在尝试编译 运行 scala.js 基础教程,网址为:
https://github.com/scala-js/scalajs-tutorial
当我通过 sbt run
执行主 class 时,我收到以下错误消息:
$ sbt run
[info] welcome to sbt 1.6.2 (Private Build Java 1.8.0_312)
[info] loading global plugins from /home/xxx/.sbt/1.0/plugins
[info] loading settings for project scalajs-tutorial-build from plugins.sbt ...
[info] loading project definition from /home/xxx/git-release/scalajs-tutorial/project
[info] loading settings for project scalajs-tutorial from build.sbt ...
[info] set current project to Scala.js Tutorial (in build file:/home/xxx/git-release/scalajs-tutorial/)
[info] Running tutorial.webapp.TutorialApp.
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'jsdom'
Require stack:
- /home/xxx/git-release/scalajs-tutorial/[stdin]
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at codeWithJSDOMContext.js:3:15
at codeWithJSDOMContext.js:52:3
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:305:38)
at [stdin]:2:29
at Script.runInThisContext (node:vm:129:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/xxx/git-release/scalajs-tutorial/[stdin]' ]
}
[error] org.scalajs.jsenv.ExternalJSRun$NonZeroExitException: exited with code 1
[error] at org.scalajs.jsenv.ExternalJSRun$$anon.run(ExternalJSRun.scala:195)
[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: 3 s, completed 28-Feb-2022 12:57:35 AM
这是什么原因造成的,我该如何解决?
问题很可能是您没有为您的项目安装 jsdom
。您可以通过 运行
$ npm install jsdom
在你启动 sbt 的目录中。