How can I change Node.js version in Kotlin/JS project?

Hi there.
I have an app written in Kotlin/React, and after upgrading Kotlin version from 1.8.10 to 1.8.20, I cannot compile it anymore, getting this error (with 1.8.10 it works OK):

$HOME/.gradle/nodejs/node-v18.12.1-linux-x64/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by $HOME/.gradle/nodejs/node-v18.12.1-linux-x64/bin/node)

I am on Ubuntu Linux 18.04 and do not have 2.28 glibc. I’ve found googling some advice on StackOverflow saying I should use node.js v. 16.xxx, however I do not know how to make it happen. I do not know much about JS, let alone Node.js and other framework (I am mostly Java and Kotlin/JVM developer) and all this stuff is a bit like magic black box to me, so please if you can advise, do it as if explaining to a not very smart kid. :slight_smile: I do not even know how to find out where the dependency is declared.
Thank you.

I don’t know much about Kotlin but if your only problem is that your node version is incompatible, you should look into nvm:

Thank you Benjamin, however my problem is that the incompatible version of node is downloaded by Gradle and I do not know where this dependency is defined—as said previously, it happens only after moving from Kotlin 1.8.10→1.8.20—or how to change it. I do not use node directly, actually I would prefer to not know about it at all (not a fan of JS), it is somehow “magically” used by the project dependencies.

Oh I see.

To get unstuck, it looks like you can at least manage your own node version.

Not a big fan of JS either, good news is that node install is very easy though :slight_smile:

Thanks again Benjamin, with your link I’ve been eventually able to solve this. The solution (in case anyone encounters the same or similar troubles) that worked for me was as follows:

  1. Install nvm to manage node.js versions manually:
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
  2. Install version of node.js you want to use — this way I can use even the newest one as it is not hardlinked to the unsupported glibc version, so I’ve installed v. 20.0 (after re-sourcing my bash to reflect changes in PATH made by nvm installer) — EDIT: OK, actually still using 16.x, 20.x is hardlinked:
    nvm install 16
  3. Use preinstalled node.js by gradle and do not try to download it:
    rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> { rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().download = false }
  4. Restart all the gradle daemons so that the Gradle finds newly installed version of node.js and live happily ever after (I had to also run gradle kotlinUpgradeYarnLock first).