I'm developing an application with Kotlin/JS and Gradle. I can easily add npm dependencies from the default npm registry with the implementation npm("query-string", "7.0.0")
command.
However, I cannot add an npm dependency from a different npm registry like Github Packages.
I want to add this npm dependency to my project. Without gradle I could just install the dependency by just using the command line and npm install @gitliveapp/firebase-firestore
but this doesn't work with the gradle npm command. I also tried implementation npm("@gitliveapp/firebase-firestore", "0.5.4")
but this produces the following error: Couldn't find package "@gitliveapp/[email protected]" required by "project" on the "npm" registry.
.
How can I add npm dependencies with gradle from different registries other than the npm public registry.
build.gradle
plugins {
id 'org.jetbrains.kotlin.js' version '1.5.10'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.5.0'
}
repositories {
mavenCentral()
maven { url 'https://maven.pkg.jetbrains.space/public/p/kotlin/p/kotlin/kotlin-js-wrappers' }
}
dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-test-js'
implementation group: 'org.jetbrains.kotlin-wrappers', name: 'kotlin-react', version: '17.0.2-pre.212-kotlin-1.5.10'
implementation group: 'org.jetbrains.kotlin-wrappers', name: 'kotlin-react-dom', version: '17.0.2-pre.212-kotlin-1.5.10'
implementation group: 'org.jetbrains.kotlin-wrappers', name: 'kotlin-styled', version: '5.3.0-pre.212-kotlin-1.5.10'
implementation group: 'org.jetbrains.kotlin-wrappers', name: 'kotlin-react-router-dom', version: '5.2.0-pre.212-kotlin-1.5.10'
implementation group: 'org.jetbrains.kotlin-wrappers', name: 'kotlin-css', version: '1.0.0-pre.212-kotlin-1.5.10'
implementation group: 'org.jetbrains.kotlin-wrappers', name: 'kotlin-redux', version: '4.0.5-pre.212-kotlin-1.5.10'
implementation group: 'org.jetbrains.kotlin-wrappers', name: 'kotlin-react-redux', version: '7.2.3-pre.212-kotlin-1.5.10'
implementation 'dev.gitlive:firebase-firestore:1.3.1'
implementation 'dev.gitlive:firebase-auth:1.3.1'
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0'
implementation 'org.kodein.di:kodein-di-js:7.6.0'
implementation npm("query-string", "7.0.0")
implementation npm("firebase", "8.6.8")
implementation npm("@gitliveapp/firebase-firestore", "0.5.4")
}
kotlin {
js(LEGACY) {
binaries.executable()
browser {
commonWebpackConfig {
cssSupport.enabled = true
}
}
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile).all {
kotlinOptions {
freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
}
}
build.gradle
orbuild.gradle.kts
– Francisco Mateo