How can I get the Scala .js 1.3.0 tutorial to run - part 2? - scala.js

After moving the project to my local files system on C: now I am getting
sbt:Scala.js Tutorial> run
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Compiling 1 Scala source to C:\Users\ERIC\Documents\git\scalajs-tutorial\target\scala-2.13\classes ...
[info] Fast optimizing C:\Users\ERIC\Documents\git\scalajs-tutorial\target\scala-2.13\scala-js-tutorial-fastopt
[info] Running tutorial.webapp.TutorialApp. Hit any key to interrupt.
internal/modules/cjs/loader.js:834
throw err;
^
Error: Cannot find module 'jsdom'
Require stack:
- C:\Users\ERIC\Documents\git\scalajs-tutorial\[stdin]
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:903:19)
at require (internal/modules/cjs/helpers.js:74:18)
at codeWithJSDOMContext.js:3:15
at codeWithJSDOMContext.js:52:3
at Script.runInThisContext (vm.js:120:18)
at Object.runInThisContext (vm.js:309:38)
at [stdin]:2:29
at Script.runInThisContext (vm.js:120:18) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\Users\\ERIC\\Documents\\git\\scalajs-tutorial\\[stdin]' ]
}
[error] org.scalajs.jsenv.ExternalJSRun$NonZeroExitException: exited with code 1
[error] at org.scalajs.jsenv.ExternalJSRun$$anon$1.run(ExternalJSRun.scala:186)
[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: 6 s, completed Oct. 16, 2020, 9:53:33 a.m.
Also
sbt:Scala.js Tutorial> evicted
[warn] Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[warn] * org.scala-js:scalajs-library_2.13:1.3.0 is selected over 1.0.0
[warn] +- scala-js-tutorial:scala-js-tutorial_sjs1_2.13:0.1.0-SNAPSHOT (depends on 1.3.0)
[warn] +- org.scala-js:scalajs-dom_sjs1_2.13:1.1.0 (depends on 1.0.0)
[success] Total time: 0 s, completed Oct. 16, 2020, 10:18:13 a.m.
Has Scala.js 1.3.0 been tested with the tutorial at (https://github.com/scala-js/scalajs-tutorial)
yet?

It's kinda buried, but the tutorial linked from the repo mentions that you need to install jsdom separately:
This will use the jsdom library to simulate a DOM in Node.js. Note that you need to install it separately using
$ npm install jsdom
After reloading, you can invoke run successfully

Related

In scala.js, what are the possible causes of "Error: Cannot find module 'jsdom'"?

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?
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.

java.lang.RuntimeException: You must run the `stage` task before deploying your app when running `sbt stage deployHeroku`

I am trying to deploy my application to Heroku using sbt-nativepackager and sbt-heroku.
My code is available at https://github.com/hhimanshu/sbt101/tree/m5 (branch is m5)
When I run sbt stage deployHeroku, the application fails as below
➜ sbt101 git:(m5) ✗ sbt stage deployHeroku
[info] Loading global plugins from /Users/harit/.sbt/1.0/plugins
[info] Loading settings for project sbt101-build from plugins.sbt ...
[info] Loading project definition from /Users/harit/code/sc/sbt101/project
[info] Loading settings for project root from build.sbt ...
[info] Set current project to sbt101 (in build file:/Users/harit/code/sc/sbt101/)
[info] Packaging /Users/harit/code/sc/sbt101/api/target/scala-2.12/api_2.12-0.1.0-SNAPSHOT-sources.jar ...
[info] Done packaging.
[info] Wrote /Users/harit/code/sc/sbt101/api/target/scala-2.12/api_2.12-0.1.0-SNAPSHOT.pom
[info] Wrote /Users/harit/code/sc/sbt101/calculators/target/scala-2.12/calculators_2.12-0.1.0-SNAPSHOT.pom
[info] Main Scala API documentation to /Users/harit/code/sc/sbt101/api/target/scala-2.12/api...
[info] Compiling 1 Scala source to /Users/harit/code/sc/sbt101/api/target/scala-2.12/classes ...
model contains 3 documentable templates
[info] Done compiling.
[info] Main Scala API documentation successful.
[info] Packaging /Users/harit/code/sc/sbt101/api/target/scala-2.12/api_2.12-0.1.0-SNAPSHOT-javadoc.jar ...
[info] Packaging /Users/harit/code/sc/sbt101/api/target/scala-2.12/api_2.12-0.1.0-SNAPSHOT.jar ...
[info] Done packaging.
[info] Main Scala API documentation to /Users/harit/code/sc/sbt101/calculators/target/scala-2.12/api...
[info] Compiling 1 Scala source to /Users/harit/code/sc/sbt101/calculators/target/scala-2.12/classes ...
[info] Done packaging.
[warn] there was one feature warning; re-run with -feature for details
model contains 5 documentable templates
[warn] one warning found
[info] Main Scala API documentation successful.
[info] Packaging /Users/harit/code/sc/sbt101/calculators/target/scala-2.12/calculators_2.12-0.1.0-SNAPSHOT-javadoc.jar ...
[info] Done packaging.
[warn] there was one deprecation warning (since 2.11.0); re-run with -deprecation for details
[warn] there was one feature warning; re-run with -feature for details
[warn] two warnings found
[info] Done compiling.
[warn] Multiple main classes detected. Run 'show discoveredMainClasses' to see the list
[info] Packaging /Users/harit/code/sc/sbt101/calculators/target/scala-2.12/calculators_2.12-0.1.0-SNAPSHOT.jar ...
[info] Done packaging.
[success] Total time: 4 s, completed 10-May-2019 4:20:03 PM
[error] java.lang.RuntimeException: You must run the `stage` task before deploying your app!
[error] at com.heroku.sbt.SbtApp.packageType(SbtApp.scala:142)
[error] at com.heroku.sbt.SbtApp.prepare(SbtApp.scala:111)
[error] at com.heroku.sdk.deploy.App.deploy(App.java:60)
[error] at com.heroku.sbt.SbtApp.deploy(SbtApp.scala:98)
[error] at com.heroku.sbt.HerokuPlugin$autoImport$.$anonfun$baseHerokuSettings$1(HerokuPlugin.scala:53)
[error] at com.heroku.sbt.HerokuPlugin$autoImport$.$anonfun$baseHerokuSettings$1$adapted(HerokuPlugin.scala:26)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
[error] at sbt.std.Transform$$anon$4.work(System.scala:67)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error] at sbt.Execute.work(Execute.scala:278)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
2019-05-10 16:20:03,606 Log4j2-TF-1-AsyncLogger[AsyncContext#cb644e]-1 ERROR Attempted to append to non-started appender heroku-logger
[error] (Compile / deployHeroku) You must run the `stage` task before deploying your app!
2019-05-10 16:20:03,607 Log4j2-TF-1-AsyncLogger[AsyncContext#cb644e]-1 ERROR Attempted to append to non-started appender heroku-logger
[error] Total time: 0 s, completed 10-May-2019 4:20:03 PM
However, using the Heroku toolbelt on command-line, I have been successful in deploying my app
➜ sbt101 git:(m5) ✗ git push heroku m5:master
The the app runs at https://h2-sbt101.herokuapp.com/rates
Can someone please help me understand what I may be missing?
I had the same problem. sbt deployHeroku looks for the directory target/universal/stage (see the source). However, it seems to look for it in the root project which may not be the one with the staged directory. For example, in the OP's log, it seems there are several projects called api and calculator. In my case, the correct one (containing the server code) was server.
So sbt stage server/deployHeroku worked for me.

Scalc SBT compile failing

I am trying to follow code from below link
http://spark.apache.org/docs/latest/quick-start.html
But when I am trying to create package it is failing. I want to know 2 thinks
obviously, why it is failing
why it is showing older version of the scala, while I mentioned 2.11
Below is the error message.
[info] Set current project to default-0464ce (in build file:/home/ubuntu/simple_sbt/)
[info] Updating {file:/home/ubuntu/simple_sbt/}default-0464ce...
[info] Resolving org.scala-lang#scala-library;2.9.1 ...
[info] Done updating.
[info] Compiling 1 Scala source to /home/ubuntu/simple_sbt/target/scala-2.9.1/classes...
[error] /home/ubuntu/simple_sbt/src/main/scala/SimpleApp.scala:1: object apache is not a member of package org
[error] import org.apache.spark.SparkContext
[error] ^
[error] /home/ubuntu/simple_sbt/src/main/scala/SimpleApp.scala:2: object apache is not a member of package org
[error] import org.apache.spark.SparkContext._
[error] ^
[error] two errors found
[error] {file:/home/ubuntu/simple_sbt/}default-0464ce/compile:compile: Compilation failed
[error] Total time: 2 s, completed Aug 30, 2016 3:19:18 AM
when you run sbt package , sometimes it fails as there are no dependencies that are downloaded and will be resolved for the files imported.
Try running, sbt run first and then sbt package . sbt run should bring in all the dependencies on top of which packaging and compiling will be possible.
If the above does not solves your problem, you need to share your sbt build file and the environment that you are using. In which directory you are running these commands, will also play a role.

container:start Not a valid key: start at Scalatra-website-examples/deployment

I'm trying to follow this tutorial about scalatra deployment.
But I get error on > container:start, I very new to scala and have no idea what to do, googling result tells me to setup xsbt-web-plugin, but is it right? isn't examples need to fully independent for such custom dependencies or it is scala way?
upd(console output):
➜ scalatra-heroku git:(master) sbt
[info] Loading project definition from /Users/user1/folder1/scalatra-website-examples/2.4/deployment/scalatra-heroku/project
[info] Compiling 1 Scala source to /Users/user1/folder1/scalatra-website-examples/2.4/deployment/scalatra-heroku/project/target/scala-2.10/sbt-0.13/classes...
[warn] there were 1 deprecation warning(s); re-run with -deprecation for details
[warn] one warning found
[info] Set current project to Heroku Example (in build file:/Users/user1/folder1/scalatra-website-examples/2.4/deployment/scalatra-heroku/)
> container:start
[error] Not a valid key: start (similar: state, startYear, target)
[error] container:start
[error]
It looks like that README is messed up. Try this example instead:
https://github.com/kissaten/scalatra-heroku
And you can always follow this guide:
http://scalatra.org/2.4/guides/deployment/heroku.html

I couldn't import 'Existing Maven Projects' of i-jetty

They said,
cd $IJETTY_HOME/console
mvn clean install
This will produce a war file in $IJETTY_HOME/console/webapp/target, and also the apk in $IJETTY_HOME/console/apk/target (although as we mentioned, you're probably not interested in that).
but I got following error (...oh, my god. I can not upload image ;0 )
**
[INFO] --- exec-maven-plugin:1.2:exec (generate-dex) # console ---
Unable to access jarfile ${env.ANDROID_HOME}/platform-tools/lib/dx.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] I-Jetty :: Console Parent ......................... SUCCESS [0.241s]
[INFO] I-Jetty :: Console Webapp ......................... FAILURE [2.431s]
[INFO] I-Jetty :: Console Android Installer .............. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.122s
[INFO] Finished at: Thu Nov 08 19:33:47 KST 2012
[INFO] Final Memory: 14M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2:exec (generate-dex) on project console: Command execution failed. Process exited with an error: 1(Exit value: 1) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :console**
and I tried 'Building with Eclipse'
finally, I got following error similar with the one.
on Import Maven Projects,
exec-maven-plugin:1.2:exec (1 errors)
maven-antrun-plugin:1.6:run(1 errors)
maven-depoendency-plugin:2.3:unpack-dependencies(1 error)
Help me, plz.
I installed maven plug-in 1.3 with eclipse on Mac OS X Lion.
finally, I solved it by myself.
I missed export android sdk path (export ANDROID_HOME=/opt/android/android-sdk-linux_86)
and I edited pom.xml
from
<artifactId>maven-android-plugin</artifactId>
<version>2.9.0-beta-5</version>
to
<artifactId>android-maven-plugin</artifactId>
<version>3.0.0</version>
thanks.