Hello all, I am attempting to bring our existing K...
# javascript
r
Hello all, I am attempting to bring our existing Kotlin library to our JS project, I have searched through the history of this channel for "npm library" and i am able to produce a
build/js
output via
./gradlew build
. i have tried to link the
build/js
folder via
yarn link
and i also tried to npm install it by adding the absolute path to the package.json of the js project. However i am getting the error
Error: Can't resolve '@js-joda/core' in home/node/jsProject/node_modules/kotlinProject/kotlin
. I think i am not installing the dependencies correctly in the
build/js
folder when i used
./gradlew build
my
build.gradle.kts
has the following
Copy code
js(IR) {
    browser()
    binaries.library()
}
to output the
build/js
t
Do you use
kotlix-datetime
?
j
I use
Copy code
js(IR) {
		browser {}
		binaries.library()
	}
then inside my typescript project's package.json which has a relative path to the build directory:
Copy code
"dependencies": {
   "tslib": "2.3.1",
   "uhtml": "2.8.0",
   "ca":  "../../build/js/packages/my-application-ca-server"
},
then inside my index.ts, I need to import
com
first before I can do anything
Copy code
import {com} from "ca"
let blah = com.myapplication.Blah()
r
i imported the plug in
id("dev.petuska.npm.publish") version "2.0.4"
and i was able to build and get
build/js/packages/kotlin-shared/kotlin/kotlin-shared.d.ts
and
build/js/packages/kotlin-shared/kotlin/kotlin-shared.js
i then added the file path to my package.json, but when i try to import it in my JS project, i get
Copy code
Error: Cannot find module '@js-joda/core'
    at webpackMissingModule
am i missing a npm install within the output package itself?
b
Yes, you need a separate npm/yarn install
Have another look at linked ts-consumer setup
r
thank you! I did a yarn install within the package and its working now ❤️
🎉 2