kotlinx.serialization: Gradle configuration error: Cannot add extension with name 'kotlinNodeJs'

In multiplatform project which is also muiltiproject: as soon as I add id 'kotlinx-serialization' version '1.3.40' to plugins of one of subprojects, gradle can no longer configure other subprojects and fails with the following error:

Cannot add extension with name ‘kotlinNodeJs’, as there is an extension already registered with that name.

Environment

  • Kotlin version: 1.3.40
  • Kotlin platforms: Multiplatform
  • Gradle version: 4.10.3

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (6 by maintainers)

Commits related to this issue

Most upvoted comments

I was able to replicate the problem. The issue occurs when I include a Kotlin multi-platform project with browser support in another that uses “kotlinx.serialization” library. I will create a project with that problem later.

I get this issue when I try to apply the plugin into a Kotlin JS project for browsers. This is the complete error:

Could not create an instance of type org.jetbrains.kotlin.gradle.targets.js.subtargets.KotlinBrowserJs.
> Failed to apply plugin [class 'org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin']
   > Cannot add extension with name 'kotlinNodeJs', as there is an extension already registered with that name.

I am using these plugins:

plugins {
    id("org.jetbrains.kotlin.js") version "1.3.72"
    kotlin("plugin.serialization") version "1.3.72"
}

I tried to use (apply false) but this did not work.