# NPM dependencies with Kotlin 1.3.40

**URL:** <https://discuss.kotlinlang.org/t/npm-dependencies-with-kotlin-1-3-40/13174>\
**Category:** JavaScript\
**Created:** [June 22, 2019, 8:58am UTC](https://discuss.kotlinlang.org/t/npm-dependencies-with-kotlin-1-3-40/13174 "2019-06-22T08:58:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sschuberth](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/sschuberth/32/8317_2.png) [@sschuberth](https://discuss.kotlinlang.org/u/sschuberth)\
**Post date:** [June 22, 2019, 8:58am UTC](https://discuss.kotlinlang.org/t/npm-dependencies-with-kotlin-1-3-40/13174/1 "2019-06-22T08:58:30Z")

</div>

Hi,

based on the code snippet in the “Experimental support for NPM and Webpack” section at [https://blog.jetbrains.com/kotlin/2019/06/kotlin-1-3-40-released/](https://blog.jetbrains.com/kotlin/2019/06/kotlin-1-3-40-released/) I’m trying to declare NPM dependencies like

```auto
plugins {
    kotlin("js") version "1.3.40"
}

repositories {
    jcenter()
}

dependencies {
    implementation(npm("react", "^16.8.1"))
}

```

But the `npm` symbol cannot be found, and I also didn’t find a matching import. How can I make this work?

Thanks!

---

<div class="post-metadata">

**Author:** ![Prototik](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/prototik/32/6489_2.png) [@Prototik](https://discuss.kotlinlang.org/u/Prototik)\
**Post date:** [June 22, 2019, 11:49am UTC](https://discuss.kotlinlang.org/t/npm-dependencies-with-kotlin-1-3-40/13174/2 "2019-06-22T11:49:55Z")

</div>

You need to declare dependencies at kotlin source set, not global dependencies container:

```
plugins {
    kotlin("js") version "1.3.40"
}

repositories {
    jcenter()
}

kotlin {
    target {
        // You can drop browser or node if you targeting only one
        nodejs()
        browser()
    }

    sourceSets["main"].dependencies {
        implementation(npm("react", "^16.8.1"))
    }
}

```

If you plan to use multiplatform plugin, you need to use slightly different things:

```
plugins {
    kotlin("multiplatform") version "1.3.40"
}

repositories {
    jcenter()
}

kotlin {
    js {
        nodejs()
        browser()
    }
    
    jvm {
        // options for jvm
    }

    sourceSets["jsMain"].dependencies {
        implementation(npm("react", "^16.8.1"))
    }
}

```

---

<div class="post-metadata">

**Author:** ![sschuberth](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/sschuberth/32/8317_2.png) [@sschuberth](https://discuss.kotlinlang.org/u/sschuberth)\
**Post date:** [June 22, 2019, 7:18pm UTC](https://discuss.kotlinlang.org/t/npm-dependencies-with-kotlin-1-3-40/13174/3 "2019-06-22T19:18:32Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![pdvrieze](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/pdvrieze/32/1882_2.png) [@pdvrieze](https://discuss.kotlinlang.org/u/pdvrieze)\
**Post date:** [June 29, 2019, 2:10pm UTC](https://discuss.kotlinlang.org/t/npm-dependencies-with-kotlin-1-3-40/13174/4 "2019-06-29T14:10:17Z")

</div>

Does anyone have module dependencies working for the multiplatform jsTest tasks? My project has multiple modules/projects (they are multiplatform modules). I’m trying to test the topmost module (the one that depends on the others), but the javascript is not even built.

Never mind. It seems that marking them browser and/or nodejs will do the deal.

---

<div class="post-metadata">

**Author:** ![monchi](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/monchi/32/6581_2.png) [@monchi](https://discuss.kotlinlang.org/u/monchi)\
**Post date:** [July 18, 2019, 10:41pm UTC](https://discuss.kotlinlang.org/t/npm-dependencies-with-kotlin-1-3-40/13174/5 "2019-07-18T22:41:45Z")

</div>

Alternative way:

```auto
nodeJs.packageJson {
    dependencies["react"] = "^16.8.1"
}

```

---

<div class="post-metadata">

**Author:** ![nbilyk](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/nbilyk/32/1483_2.png) [@nbilyk](https://discuss.kotlinlang.org/u/nbilyk)\
**Post date:** [September 19, 2019, 9:49pm UTC](https://discuss.kotlinlang.org/t/npm-dependencies-with-kotlin-1-3-40/13174/6 "2019-09-19T21:49:58Z")

</div>

For browser deployment, how does one collect these dependencies?

For non-npm dependencies I can get them via the compilation’s runtimeDependencyFiles property, but I can’t resolve that property once I’ve added an npm dependency

(Could not resolve all files for configuration ‘:new-project:jsRuntimeClasspath’.)
