
Once an npm dependency is installed, you can use its API in your code as described in Calling JS from Kotlin. OptionalDependencies via optionalNpm(.), and To learn more about when each type of dependency can best be used, have a look at the official documentation linked from npm: Learn how to configure Yarn in Kotlin/JS Gradle plugin.īesides regular dependencies, there are three more types of dependencies that can be used from the Gradle DSL. It works out of the box without additional configuration, but you can tune it to specific needs. The plugin uses the Yarn package manager to download and install NPM dependencies. Like any other Gradle projects, Kotlin/JS projects support traditional Gradle dependency declarations in the dependencies section of the build script. For projects targeting Node.js, there are also an option to use an existing Node.js installation.

This allows developers to build, run, and test simple projects without additional configuration. This includes downloading and installing the required environment and dependencies for running and testing the application. The Kotlin/JS plugin automatically configures its tasks for working with the selected environment. (This is typically faster than creating executable files, and can be a possible optimization when dealing with non-leaf modules of your project.) In those cases, omitting binaries.executable() will cause the compiler to only generate Kotlin-internal library files, which can be used from other projects, but not run on their own. This is the default behavior when using the current Kotlin/JS compiler, but the instruction is explicitly required if you are working with the Kotlin/JS IR compiler, or have set kotlin.js.=false in your gradle.properties.


The instruction binaries.executable() explicitly instructs the Kotlin compiler to emit executable.
