# More Issues with the ScalaJS Tutorial

**URL:** <https://users.scala-lang.org/t/more-issues-with-the-scalajs-tutorial/1525>\
**Category:** Question\
**Created:** [August 10, 2017, 4:55pm UTC](https://users.scala-lang.org/t/more-issues-with-the-scalajs-tutorial/1525 "2017-08-10T16:55:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hossein](https://users.scala-lang.org/user_avatar/users.scala-lang.org/hossein/32/159_2.png) [@Hossein](https://users.scala-lang.org/u/Hossein)\
**Post date:** [August 10, 2017, 4:55pm UTC](https://users.scala-lang.org/t/more-issues-with-the-scalajs-tutorial/1525/1 "2017-08-10T16:55:46Z")

</div>

Dear all,

Proceeding with the ScalaJS basic tutorial:

> **[Basic tutorial](http://www.scala-js.org/doc/tutorial/basic/)**
>
> Harness the Scala and JavaScript ecosystems to develop robust apps for browsers, serverless, and Node.js.

I faced two issues at steps 5 and 6. Here they are:

- Step 5: I don’t get any reaction to clicking the button. (For the reference, I am including my Scala file at the P.S. [1].) Everything builds successfully though. Is that the behaviour I should expect?

- Step 6: After having `jsdom` installed, I still get a type error when trying `run` in sbt. The error message can again be found in the P.S. [2]. Relevant to that might be the few warnings I get at the end of `jsdom` installation. I am putting those in the P.S. too [3]. Any idea what’s going wrong? (Note that I am performing the installation as the admin. So, there is no authentication issue involved.)

TIA,  
–Hossein

P.S.

[1] The Scala file:

```
package tutorial.webapp

import org.scalajs.jquery.jQuery

object TutorialApp {
  def addClickedMessage(): Unit = {
    jQuery("body").append("<p>You clicked the button.</p>")
  }
  
  def setupUI(): Unit = {
    jQuery("#click-me-button").click(() => addClickedMessage())
    jQuery("body").append("<p>Hello World!</p>")
  }

  def main(args: Array[String]): Unit = {
    jQuery(() => setupUI())
  }
}

```

[2] The `run` error:

> \> run  
> [info] Running tutorial.webapp.TutorialApp  
> [error] module.js:471  
> [error] throw err;  
> [error] ^  
> [error]  
> [error] Error: Cannot find module ‘jsdom’  
> [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 [stdin]:39:13  
> [error] at [stdin]:67:3  
> [error] at ContextifyScript.Script.runInThisContext (vm.js:25:33)  
> [error] at Object.runInThisContext (vm.js:97:38)  
> [error] at Object. ([stdin]-wrapper:6:22)  
> [error] at Module.\_compile (module.js:570:32)  
> org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: Node.js with JSDOM exited with code 1  
> at org.scalajs.jsenv.ExternalJSEnv$AbstractExtRunner.waitForVM(ExternalJSEnv.scala:119)  
> at org.scalajs.jsenv.ExternalJSEnv$ExtRunner.run(ExternalJSEnv.scala:168)  
> at org.scalajs.sbtplugin.ScalaJSPluginInternal$.org$scalajs$sbtplugin$ScalaJSPluginInternal$$jsRun(ScalaJSPluginInternal.scala:718)  
> at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$73$$anonfun$apply$50$$anonfun$apply$51.apply(ScalaJSPluginInternal.scala:860)  
> at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$73$$anonfun$apply$50$$anonfun$apply$51.apply(ScalaJSPluginInternal.scala:854)  
> 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 with JSDOM exited with code 1  
> [error] Total time: 2 s, completed 10-Aug-2017 17:53:39

[3] The `jsdom` installation warnings:

$npm install jsdom  
C:\Windows\system32  
`– jsdom@11.1.0  
±- abab@1.0.3  
±- acorn@4.0.13  
±- acorn-globals@3.1.0  
±- array-equal@1.0.0  
±- content-type-parser@1.0.1  
±- cssom@0.3.2  
±- cssstyle@0.2.37  
±- escodegen@1.8.1  
| ±- esprima@2.7.3  
| ±- estraverse@1.9.3  
| ±- esutils@2.0.2  
| ±- optionator@0.8.2  
| | ±- deep-is@0.1.3  
| | ±- fast-levenshtein@2.0.6  
| | ±- levn@0.3.0  
| | ±- prelude-ls@1.1.2  
| | ±- type-check@0.3.2  
| |\ `-- wordwrap@1.0.0 |\ `– source-map@0.2.0  
| `– amdefine@1.0.1  
±- html-encoding-sniffer@1.0.1  
±- nwmatcher@1.4.1  
±- parse5@3.0.2  
| `– @types/node@6.0.85  
±- pn@1.0.0  
±- request@2.81.0  
| ±- aws-sign2@0.6.0  
| ±- aws4@1.6.0  
| ±- caseless@0.12.0  
| ±- combined-stream@1.0.5  
| |\ `-- delayed-stream@1.0.0 | +-- extend@3.0.1 | +-- forever-agent@0.6.1 | +-- form-data@2.1.4 | | \`– asynckit@0.4.0  
| ±- har-validator@4.2.1  
| | ±- ajv@4.11.8  
| | | ±- co@4.6.0  
| | | `– json-stable-stringify@1.0.1  
| | | `– jsonify@0.0.0  
| |`– har-schema@1.0.5  
| ±- hawk@3.1.3  
| | ±- boom@2.10.1  
| | ±- cryptiles@2.0.5  
| | ±- hoek@2.16.3  
| | `– sntp@1.0.9  
| ±- http-signature@1.1.1  
| | ±- assert-plus@0.2.0  
| | ±- jsprim@1.4.1  
| | | ±- assert-plus@1.0.0  
| | | ±- extsprintf@1.3.0  
| | | ±- json-schema@0.2.3  
| | | `– verror@1.10.0  
| | | ±- assert-plus@1.0.0  
| | | `-- core-util-is@1.0.2 | | \`– sshpk@1.13.1  
| | ±- asn1@0.2.3  
| | ±- assert-plus@1.0.0  
| | ±- bcrypt-pbkdf@1.0.1  
| | ±- dashdash@1.14.1  
| | | `– assert-plus@1.0.0  
| | ±- ecc-jsbn@0.1.1  
| | ±- getpass@0.1.7  
| | | `– assert-plus@1.0.0  
| | ±- jsbn@0.1.1  
| | `– tweetnacl@0.14.5  
| ±- is-typedarray@1.0.0  
| ±- isstream@0.1.2  
| ±- json-stringify-safe@5.0.1  
| ±- mime-types@2.1.16  
| | `– mime-db@1.29.0  
| ±- oauth-sign@0.8.2  
| ±- performance-now@0.2.0  
| ±- qs@6.4.0  
| ±- safe-buffer@5.1.1  
| ±- stringstream@0.0.5  
| ±- tunnel-agent@0.6.0  
| `– uuid@3.1.0  
±- request-promise-native@1.0.4  
| ±- request-promise-core@1.1.1  
| | `– lodash@4.17.4  
| `– stealthy-require@1.1.1  
±- sax@1.2.4  
±- symbol-tree@3.2.2  
±- tough-cookie@2.3.2  
| `– punycode@1.4.1  
±- webidl-conversions@4.0.1  
±- whatwg-encoding@1.0.1  
| `– iconv-lite@0.4.13  
±- whatwg-url@6.1.0  
| ±- lodash.sortby@4.7.0  
| `– tr46@0.0.3  
`– xml-name-validator@2.0.1

npm WARN enoent ENOENT: no such file or directory, open ‘C:\Windows\system32\package.json’  
npm WARN system32 No description  
npm WARN system32 No repository field.  
npm WARN system32 No README data  
npm WARN system32 No license field.

---

<div class="post-metadata">

**Author:** ![Hossein](https://users.scala-lang.org/user_avatar/users.scala-lang.org/hossein/32/159_2.png) [@Hossein](https://users.scala-lang.org/u/Hossein)\
**Post date:** [August 14, 2017, 11:07am UTC](https://users.scala-lang.org/t/more-issues-with-the-scalajs-tutorial/1525/2 "2017-08-14T11:07:45Z")

</div>

For the record, I figured out what was wrong in the case of [1]. I had mistakenly replaced the following line in my `scalajs-tutorial-fastopt.html`

`<script type="text/javascript" src="./target/scala-2.12/scala-js-tutorial-fastopt.js"></script>`

with

`<script type="text/javascript" src="http://cdn.jsdelivr.net/jquery/2.1.1/jquery.js"></script>`.

Whereas, I should have added the latter rather than replacing the former with it.

Regarding [2], I’m still getting the same exception on failure to locate `jsdom` upon `run`.

---

<div class="post-metadata">

**Author:** ![Hossein](https://users.scala-lang.org/user_avatar/users.scala-lang.org/hossein/32/159_2.png) [@Hossein](https://users.scala-lang.org/u/Hossein)\
**Post date:** [August 14, 2017, 2:17pm UTC](https://users.scala-lang.org/t/more-issues-with-the-scalajs-tutorial/1525/3 "2017-08-14T14:17:41Z")

</div>

Here is more update:

I fixed the `npm install jsdom` problem using the guidelines provided by Golo Roden here:

> <https://stackoverflow.com/questions/24468041/npm-install-gives-error-cant-find-a-package-json-file>

But, the problem with calling `run` from within `sbt` is still around (even when I run `sbt` as the admin).
