title: How to fix "Its dependency 'kotlinx-coroutines-core' was not found."
body: <p>I followed this tutorial to create a kotlin->js project: <a href="https://kotlinlang.org/docs/tutorials/javascript/getting-started-gradle/getting-started-with-gradle.html" rel="noreferrer">https://kotlinlang.org/docs/tutorials/javascript/getting-started-gradle/getting-started-with-gradle.html</a></p>
  
  <p>Next, I followed these instructions to use coroutines in my code: <a href="https://github.com/kotlin/kotlinx.coroutines/blob/master/README.md#using-in-your-projects" rel="noreferrer">https://github.com/kotlin/kotlinx.coroutines/blob/master/README.md#using-in-your-projects</a></p>
  
  <p>Everything was fine to far, no errors marked in the code and I could build my js application without any error messages. However, my js scripts are not running in the browser and I get the above mentioned error message in the browser console.
  Does any of you here know what I missed or might have configured wrong?</p>
  
  <p>Here's my build.gradle</p>
  
  <pre><code>group 'de.berlin'
  version '1.0-SNAPSHOT'
  
  buildscript {
      ext.kotlin_version = '1.3.31'
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
      }
  }
  
  apply plugin: 'kotlin2js'
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
      testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
      compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0-M1"
      compile("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.0-M1")
      compile "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.0-M1"
  }
  
  compileKotlin2Js.kotlinOptions.sourceMap = true
  compileKotlin2Js.kotlinOptions.outputFile = "${projectDir}/web/js/myApp.js"
  compileKotlin2Js.kotlinOptions.suppressWarnings = false
  compileKotlin2Js.kotlinOptions.verbose = true
  
  build.doLast {
      configurations.compile.each { File file -&gt;
          copy {
              includeEmptyDirs = false
  
              from zipTree(file.absolutePath)
              into "${projectDir}/web/js/lib"
              include { fileTreeElement -&gt;
                  def path = fileTreeElement.path
                  path.endsWith(".js") &amp;&amp; (path.startsWith("META-INF/resources/") || !path.startsWith("META-INF/"))
              }
          }
      }
  
      copy {
          includeEmptyDirs = false
          from "${buildDir}/resources/main"
          into "${projectDir}/web"
      }
  }
  
  clean.doFirst {
      delete "${projectDir}/web"
  
  }
  </code></pre>
  
  <p>Everything compiles without any error message but I get the following error message in the browser console: 
  ""Its dependency 'kotlinx-coroutines-core' was not found. Please, check whether 'kotlinx-coroutines-core' is loaded prior to '(projectname)'."</p>
  
  <p>A more detailled inspection shows that /web/js/lib only contains kotlin.js, shouldn't kotlinx-coroutines-core be also there because it's part of the depencency block and schould be copied in the build.doLast-step?
  I also noticed that the comiled js file contains the following:</p>
  
  <pre><code>if (typeof kotlin === 'undefined') {
    throw new Error("Error loading module 'myApp'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'myApp'.");
  }
  if (typeof this['kotlinx-coroutines-core'] === 'undefined') {
    throw new Error("Error loading module 'myApp'. Its dependency 'kotlinx-coroutines-core' was not found. Please, check whether 'kotlinx-coroutines-core' is loaded prior to 'myApp'.");
  }
  </code></pre>
  
  <p>Why is it this['kotlinx-coroutines-core'] and not kotlinx-coroutines-core (like in the line above)?</p>