Hey I'm trying to add Okio to my js-node KMP proje...
# squarelibraries
t
Hey I'm trying to add Okio to my js-node KMP project as described here https://square.github.io/okio/multiplatform/, but Android studio can't resolve node filesystem
Failed to resolve: com.squareup.okio:okio-nodefilesystem:3.6.0
I have no problem with the core
com.squareup.okio:okio:3.6.0
Instead of
Copy code
js {
            dependencies {
                implementation(libs.okio.nodefilesystem)
            }
            binaries.executable()
            nodejs {
                generateTypeScriptDefinitions()
            }
        }
I need to do
Copy code
js {
            jsMain.dependencies {
                implementation(libs.okio.nodefilesystem)
            }
            binaries.executable()
            nodejs {
                generateTypeScriptDefinitions()
            }
        }
👍 1
j
The dependencies should be declared in sourceSets, not as part of the target
Your first snippet does not match what's on the website
t
The snippet was only for the JS target, this is the sourcesets from my build.gradle.kts file 🙂
Copy code
sourceSets {
        commonMain.dependencies {
            implementation(libs.ktor.client.core)
            implementation(libs.kotlinx.coroutines.core)
            implementation(libs.okio)
        }

        androidMain.dependencies {
            implementation(libs.ktor.client.okhttp)
            implementation(libs.kotlinx.coroutines.android)

        }

        iosMain.dependencies {
            implementation(libs.ktor.client.darwin)
        }

        js {
            jsMain.dependencies {
                implementation(libs.okio.nodefilesystem)
            }
            binaries.executable()
            nodejs {
                generateTypeScriptDefinitions()
            }
        }

        commonTest.dependencies {
            implementation(libs.kotlin.test)
        }
    }
j
You are mixing the target declaration with the sourceSet configuration
The js { } block should be at the same level of sourceSets { }
But jsMain belongs within sourceSets
t
Arh I see, so in this way
Copy code
sourceSets {
        commonMain.dependencies {
            implementation(libs.ktor.client.core)
            implementation(libs.kotlinx.coroutines.core)
            implementation(libs.okio)
        }

        androidMain.dependencies {
            implementation(libs.ktor.client.okhttp)
            implementation(libs.kotlinx.coroutines.android)

        }

        iosMain.dependencies {
            implementation(libs.ktor.client.darwin)
        }
        jsMain.dependencies {
            implementation(libs.okio.nodefilesystem)
        }
        
        commonTest.dependencies {
            implementation(libs.kotlin.test)
        }
    }

    js {

        binaries.executable()
        nodejs {
            generateTypeScriptDefinitions()
        }
    }
j
Yep!
t
It is funny though, the other thing actually worked, I got generated the typescript definitions and the code to save to filesystem works from my node application 🤷