Home > Blockchain >  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'"

Time:03-02

I'm trying to compile and run the scala.js basic tutorial at:

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

When I execute the main class by sbt run, I got the following error message:

$ 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

What's the cause of it and how do I fix it?

CodePudding user response:

The problem is most likely that you did not install jsdom for your project. You can do so by running

$ npm install jsdom

in the directory where you launch sbt.

  • Related