Open tribbloid opened 5 years ago
Hi @tribbloid thank you for using the example. Actually readme was old without using jquery. Since it is using jquery (see https://github.com/duwamish-os/introv.scalajs/blob/master/src/main/scala/com/duwamish/introv/IntroV.scala#L13) code can not run in nodejs without loading jquery.
def main(args: Array[String]): Unit = {
$(() => {
g.console.log("welcome to IntroV v1")
$("#headerText").text("welcome all the introvs")
})
}
But if you keep the codebase to pure javascript without jquery, it would work fine,
def main(args: Array[String]): Unit = {
//$(() => {
g.console.log("welcome to IntroV v1")
//$("#headerText").text("welcome all the introvs")
//})
}
see sbt run output
$ node_modules/sbt/bin/sbt run
[info] Loading settings from idea.sbt,credentials.sbt ...
[info] Loading global plugins from /Users/a1353612/.sbt/1.0/plugins
[info] Loading settings from plugins.sbt ...
[info] Loading project definition from /Users/a1353612/buybest/sc212/scalajs-on-nodejs/project
[info] Loading settings from build.sbt ...
[info] Set current project to scalajs-on-nodejs (in build file:/Users/a1353612/buybest/sc212/scalajs-on-nodejs/)
[info] Compiling 1 Scala source to /Users/a1353612/buybest/sc212/scalajs-on-nodejs/target/scala-2.12/classes ...
[info] Done compiling.
[info] Fast optimizing /Users/a1353612/buybest/sc212/scalajs-on-nodejs/src/main/resources/scalajs-on-nodejs-opt.js
[info] Running com.duwamish.introv.IntroV
welcome to IntroV v1
[success] Total time: 6 s, completed Jan 5, 2019 1:03:55 PM
I will see how can I load jQuery before running the code.
Let me know if you need more help :)
Here is the full log tested on Ubuntu 18.04 with node 4.1