Registry / kotlin-compiler

kotlin-compiler

JSON →
library2.3.21jsnpmunverified

The official Kotlin compiler from JetBrains, version 2.3.21. Kotlin is a statically typed programming language that targets the JVM, JavaScript, Wasm, and native platforms. The compiler includes support for multiplatform projects, coroutines, and a rich standard library. Released on a frequent cadence with stable releases every few months and previews. Key differentiators include full interoperability with Java, concise syntax, and safety features like null safety and sealed classes. This package provides the command-line compiler (kotlinc) and is also used as a dependency by build tools like Gradle and Maven.

npm install kotlin-compiler
INSTALL
IMPORT
SIG · KOTLIN-COMPILER
K
kotlin-compiler
javascriptv2.3.21
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

kotlin
import kotlin.*
import org.jetbrains.kotlin.*
Standard library imports use the 'kotlin' root package. Use 'import kotlin.*' over 'org.jetbrains.kotlin.*' which is for internal compiler APIs.
kotlinx.coroutines
import kotlinx.coroutines.*
import kotlin.coroutines.*
Coroutines are in the 'kotlinx.coroutines' package, not 'kotlin.coroutines' (which is for low-level primitives).
KotlinCompile task (Gradle)
tasks.withType<KotlinCompile> { kotlinOptions.jvmTarget = "1.8" }
compileKotlin { kotlinOptions.jvmTarget = "1.8" }
Use typed task configuration (KotlinCompile) instead of the untyped 'compileKotlin' for better IDE support.

Shows basic compilation of a Kotlin source file to a runnable JAR using the command-line compiler.

// hello.kt fun main() { println("Hello, Kotlin!") } // Compile: kotlinc hello.kt -include-runtime -d hello.jar // Run: java -jar hello.jar
kotlinc --version
Debug
Known issues
breakingKotlin 2.0+ uses K2 compiler by default, which may cause issues with some code that relied on old compiler behavior.
fix
Enable K1 compiler via -Xuse-k1 compiler flag or update code to be compatible with K2.
affects: >=2.0.0
gotchaUsing 'kotlin' Gradle plugin version must match compiler version (e.g., Kotlin 2.3.21 plugin requires compiler 2.3.21).
fix
Ensure plugin and compiler versions are consistent. Use version catalog or ext.kotlinVersion.
affects: >=1.0
deprecatedKotlin Android Extensions plugin is deprecated in Kotlin 1.8 and removed in 2.0.
fix
Migrate to Jetpack View Binding or Compose.
affects: >=1.8.0
Errors
Common errors & fixes
error: unresolved reference: kotlinx
Missing dependency for kotlinx.coroutines or kotlinx.serialization in Gradle/Maven.
fix
Add implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3' (or similar) to build.gradle.
FAILURE: Build failed with an exception. * What went wrong: Could not set unknown property 'jvmTarget' for task ':compileKotlin' of type org.jetbrains.kotlin.gradle.tasks.KotlinCompile.
Using the deprecated compileKotlin closure without typed configuration.
fix
Use tasks.named('compileKotlin', org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { kotlinOptions.jvmTarget = '1.8' }.
Upgrade
Version history
2.3.21latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
kotlin-compiler — npm install kotlin-compiler · libregistry