Simple question about Kotlin JS: I am in a project...
# getting-started
t
Simple question about Kotlin JS: I am in a project folder with a local node_modules directory. I want to create a script.kt that does an import of a module within the node_modules. I am using the command-line compiler kotlinc-js, but nothing is found. What is the magic to allow the compiler to pull in JS from the node_modules? Do I have to run the ts2kt converter? Do I need a package.json of some sort? Thank you!
b
tylerwilson: take a look to “-module-kind” option of
kotlinc-js
. You need it to generate JS code with JS module system. You can find more info about it here: https://kotlinlang.org/docs/reference/js-modules.html
Kotlin JS doesn’t work directly with libraries from node_modules. Kotlin JS has few ways to interop with JS, You can read about them here https://kotlinlang.org/docs/reference/js-interop.html
ts2kt is a tool to get Kotlin declarations from TypeScript declarations (d.ts files)