Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
Scala scala.js no puede encontrar el script del módulo js en la compilación sbt

Estoy tratando de importar un JS Script script.js en un programa scala App.scala y uso sus métodos add y divide .

Sin embargo, al ejecutar el programa, sigo recibiendo el error Cannot find module 'resources/script.js' .

La estructura de la carpeta principal de sbt se parece a la siguiente:

../principal

 /resources -script.js /scala/example -App.scala

¿Podría ayudarme a detectar el problema?

¡Gracias por adelantado!

App.scala:

 package example import scala.scalajs.js import scala.scalajs.js.annotation._ @js.native @JSImport("resources/script.js","MyType") class MyType(var x:Double, var y:Double) extends js.Object { ... } object Hello extends App { work() @JSExport def work(): Unit = { ... } }

secuencia de comandos.js:

 class MyType { constructor(x, y) { ... } add(z){ ... } divide(z){ ... } }; module.exports = {MyType};

plugins.sbt:

 addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")

construir.sbt:

 import Dependencies._ import org.scalajs.linker.interface.ModuleInitializer ThisBuild / scalaVersion := "2.13.8" ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "com.example" ThisBuild / organizationName := "example" lazy val root = (project in file(".")) .settings( name := "add", libraryDependencies += scalaTest % Test ) enablePlugins(ScalaJSPlugin) scalaJSUseMainModuleInitializer := true // ECMAScript scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.ESModule) } // CommonJS scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) } // See https://www.scala-sbt.org/1.x/docs/Using-Sonatype.html for instructions on how to publish to Sonatype.
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!