简体   繁体   中英

how to integrate kotlin with node.js

I'm new in kotlin and found that we can integrate JavaScript with kotlin but I'm not able to understand how I can achieve this with the nodejs and kotlin.

I found that I can use the javaScript with kotlin but not able to setup kotlin with javascript. Any help would be appreciated. Thanks

This blog post has a great walk through of setting up a simple nodejs app with Kotlin. All credit to the author Miquel Beltran .

You can write your app in kotlin then compile it to JavaScript and then run it with node

Here is example project on GitHub: Node js Todo app written entirely with kotlin

As mentioned, you only need to compile to js.

Check this example project .

Look at the simple configuration via build.gradle.kts files (note that there are more than one, check the sub-directories):

plugins {
    id("org.jetbrains.kotlin.js") version "1.5.10"
}

group = "com.techprd"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

kotlin {
    js {
        browser()
        nodejs()
    }
}

Load the JetBrains plugin and specify the target JS platforms (browser & nodejs).

Profit! 🎉

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM