title: scalaks-bootstrap: Uncaught ReferenceError: exports is not defined at scalajsenv.js:29
body: <p>I try to make a simple <strong>scalajs</strong> + <strong>scalajs-bootstrap</strong> application, but there is few documentation on how to set up the skeleton. The scalajs-bootstrap project has an example, but the build.sbt file is very big and it contains both the source code of the scalajs-bootstrap and the example itself.</p>
  
  <p>I tried creating a new project with only the bootstrap4 example, but when I open the index.html page on the browswer, it complains with </p>
  
  <blockquote>
    <p><code>Uncaught ReferenceError: exports is not defined at scalajsenv.js:29</code></p>
  </blockquote>
  
  <p>This is my current set-up:</p>
  
  <p>project/plugins.sbt</p>
  
  <pre><code>addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.20")
  addSbtPlugin("com.github.karasiq" % "sbt-scalajs-bundler" % "1.2.1")
  addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.13.0")
  </code></pre>
  
  <p>build.sbt</p>
  
  <pre><code>enablePlugins(ScalaJSBundlerPlugin)
  
  scalaVersion := "2.12.6"
  libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.9.7"
  libraryDependencies += "com.github.karasiq" %%% "scalajs-bootstrap-v4" % "2.3.5"
  
  npmDependencies in Compile += "jquery" -&gt; "3.2.1"
  npmDependencies in Compile += "bootstrap" -&gt; "4.1.1"
  
  mainClass in Compile := Some("com.karasiq.bootstrap4.test.frontend.BootstrapTestApp")
  scalaJSUseMainModuleInitializer := true
  
  scalaJSModuleKind := ModuleKind.CommonJSModule
  version in webpack := "4.28.4"
  emitSourceMaps := false
  </code></pre>
  
  <p>This is the source code of scalajs-bootstrap4 libray and example:
  <a href="https://github.com/Karasiq/scalajs-bootstrap" rel="nofollow noreferrer">https://github.com/Karasiq/scalajs-bootstrap</a></p>
  
  <p>This is my complete minimal example, which fails with the <code>exports is not defined</code> error:
  <a href="https://github.com/dportabella/scalajs-bootstrap4-examples" rel="nofollow noreferrer">https://github.com/dportabella/scalajs-bootstrap4-examples</a></p>
  
  <p>How to modify plugins.sbt and/or build.sbt to make this project work?</p>
  
  <hr>
  
  <p><strong>Solution</strong></p>
  
  <p>project/plugins.sbt</p>
  
  <pre><code>addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.28")
  addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.13.0")
  </code></pre>
  
  <p>build.sbt</p>
  
  <pre><code>enablePlugins(ScalaJSBundlerPlugin)
  
  scalaVersion := "2.12.8"
  libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.9.7"
  libraryDependencies += "com.github.karasiq" %%% "scalajs-bootstrap-v4" % "2.3.5"
  
  npmDependencies in Compile += "jquery" -&gt; "3.2.1"
  npmDependencies in Compile += "bootstrap" -&gt; "4.1.1"
  
  mainClass in Compile := Some("com.karasiq.bootstrap4.test.frontend.BootstrapTestApp")
  scalaJSUseMainModuleInitializer := true
  
  scalaJSModuleKind := ModuleKind.CommonJSModule
  version in webpack := "4.28.4"
  emitSourceMaps := false
  </code></pre>
  
  <p>full example: 
  <a href="https://github.com/dportabella/scalajs-bootstrap4-examples" rel="nofollow noreferrer">https://github.com/dportabella/scalajs-bootstrap4-examples</a></p>