JS IR compiler not compatible with kotlinx.serialization?

I have a multiplatform project that compiles file but if I change one line in my gradle build file:

js(LEGACY)  { ... }


js(IR) { ... }

It can’t see any of the kotlinx.serialization stuff. Errors like:

Unresolved reference: serialization (on line: import kotlinx.serialization.*)
Unresolved reference: KSerializer

A comment on this bug says serialization 1.0.0-RC is compatible with the Kotlin/JS IR compiler. I’m using an even newer version.

plugins {
  kotlin("multiplatform") version "1.4.30"
  kotlin("plugin.serialization") version "1.4.30"
   val commonMain by getting {
      dependencies {       

I’ll just use js(LEGACY) for now.

I think there is something wrong with your Gradle cache or something. I use exactly the same plugins and I have no trouble making it work.

I just deleted ~/.gradle/caches and that didn’t solve it. Do you know if there is another cache to delete?

We are using JS-IR with Serizliazation and it is OK. If the errors you see are in the idea, it is possible that you have not synced gradle with the idea. If the error is in the console gradle build, probably something wrong with caches. Try to check gradle configuration with gradle dependencies.

I get the same errors running gradle build from command line. What am I looking for in gradle dependencies? Here is the online version (I ran gradle --scan dependencies):


I tracked it down by recreating my project piece by piece. It was this line in my JS gradle config:

freeCompilerArgs = listOf(...)

That = needs to be +=.

I’ve decided to retire from programming and start a hyena milk farm in Siberia.

1 Like

Wait! Vote for KT-41985 before doing so. I’ve also mentioned your problem in KT-44958.



I am running through the same issue with the following configuration.

plugins {
    kotlin("multiplatform") version "1.5.10"
    kotlin("plugin.serialization") version "1.5.10"

group = "me.user"
version = "1.0-SNAPSHOT"

repositories {

kotlin {
    js(IR) {
        browser {
            testTask {
    sourceSets {
        all {

        val commonMain by getting {
            dependencies {
        val commonTest by getting {
            dependencies {
        val jsMain by getting
        val jsTest by getting

Using LEGACY instead just works.

Here the kind of errors it produces

Am I missing some steps?

Updating to Kotlin 1.5.20 fixes it.

The project was generated with 1.5.10 on IDEA.