gpt4 book ai didi

scala - 在scala.js中, "Error: Cannot find module ' jsdom'”的可能原因是什么?

转载 作者:行者123 更新时间:2023-12-05 03:28:09 30 4
gpt4 key购买 nike

我正在尝试编译和运行 scala.js 基础教程:

https://github.com/scala-js/scalajs-tutorial

当我通过sbt run 执行主类时,出现以下错误信息:

$ 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$1.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 - 在scala.js中, "Error: Cannot find module ' jsdom'”的可能原因是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71291130/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com