title: Access Javascript file in Kotlin/JS
body: <p>I have a bunch of Javascript files I need to access from Kotlin Code.</p>
  <p>I created a js-files directory in my root project with the needed .js files and a package.json which looks like this:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;name&quot;: &quot;js-files&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;dependencies&quot;: {
    }
  }
  
  </code></pre>
  <p>My build.gradle looks like this:</p>
  <pre class="lang-kotlin prettyprint-override"><code>plugins {
      kotlin(&quot;js&quot;)
  }
  
  version = &quot;unspecified&quot;
  
  repositories {
      mavenCentral()
  }
  
  kotlin {
      js {
          useCommonJs()
  
          nodejs()
          browser {
              webpackTask {
                  output.libraryTarget = &quot;commonjs2&quot;
              }
          }
  
          binaries.executable()
      }
  }
  
  dependencies {
      val path = rootProject.projectDir.resolve(&quot;js-files&quot;).canonicalPath
      implementation(npm(&quot;js-files&quot;, &quot;file:$path&quot;))
  }
  </code></pre>
  <p>The idea for this I got from <a href="https://stackoverflow.com/a/68305290/5608927">this post</a>.</p>
  <p>For debugging, i have the following js file in js-files:</p>
  <pre class="lang-js prettyprint-override"><code>export function func() {
      console.log(&quot;This is my test function.&quot;)
  }
  </code></pre>
  <p>and my kotlin main looks like this:</p>
  <pre class="lang-kotlin prettyprint-override"><code>@JsModule(&quot;js-files&quot;)
  external fun func()
  
  fun main() {
      func()
  }
  </code></pre>
  <p>However, when i run the project using vrowserDevelopmentRun i receive this error:</p>
  <pre><code>Module not found: Error: Can't resolve 'js-files' in 'path-to-my-project/build/js/packages/project-name-js/kotlin-dce-dev'
  </code></pre>
  <p>Maybe there is an easier way of binding my js files but after hours of research i found nothing. I'm thankful for any help.</p>