2

I want to call a local npm package in my kotlin project. At first, I tried to call a package from the npm repository using the below steps. Let's take an example of is-sorted package which checks the array whether it is sorted or not and returns a boolean value.

  1. Add the dependencies in build.gradle.kts implementation(npm("is-sorted","1.0.0"))

  2. Create an "is-sorted.kt" file under main->kotlin. Add the below annotations and function along with its return type.
    @JsModule("is-sorted")

    @JsNonModule

    external fun <T> sorted(a: Array<T>): Boolean

  3. Now under main function we have to add our print or test statement.

But when I am trying to add my local package in gradle using the same and adding it's path

implementation(npm("C:\\hitesh-kotlin-module","1.0.0"))

After the build, I am getting the below error.

Package "C:\\hitesh-kotlin-module" refers to a non-existing file '"C:\\hitesh-kotlin-module@1.0.0"'.

Does anyone know how to resolve this error and how to import a local npm package in gradle?

0 Answers0