I have been struggling to get the wasmJs target wo...
# webassembly
l
I have been struggling to get the wasmJs target working, and in this thread I was adviced to explicitly change the node version to the canary version instead. I did so, but now I'm getting a different error:
Copy code
error mocha@10.2.0: The engine "node" is incompatible with this module. Expected version ">= 14.0.0". Got "21.0.0-v8-canary202309143a48826a08"
error Found incompatible module.
> Task :kotlinNpmInstall FAILED
Apparently it doesn't understand that 21.xxxx is higher than 14? I wonder if my issues could be related to me having multiple subprojects, but I added the hack to all the modules that use nodejs, and I still get the same problem. Any suggestions?
s
Maybe try something like:
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask>().configureEach {
    args.add("--ignore-engines")
}
l
Thanks for commenting. My gradle files use groovy, so I did the following, which I believe is the same thing. (edit: Just to be clear, that is what I had done previously, and this code does not fix the problem)
Copy code
var nodeExtension = ootProject.extensions.kotlinNodeJs
nodeExtension.nodeVersion = "21.0.0-v8-anary202309143a48826a08"
nodeExtension.nodeDownloadBaseUrl = <https://nodejs.org/download/v8-canary>"

tasks.withType(org.jetbrains.kotlin.gradle.targts.js.npm.tasks.KotlinNpmInstallTask.class).conigureEach {
    if(!args.contains("--ignore-engines")) {
        args.add("--ignore-engines")
    }
}
👍 1
I added it to the end of each
build.gradle
file that contains js code, even though I've only added wasmjs support for a single subprobject at the moment. The reason for this was that I figured that perhaps there was a conflict between the different subprojects, but it didn't change anything.
In the case that someone is interested in seeing the actual project, the code is here, with the specific submodule that is being ported to wasmjs being
mpbugnum
. https://codeberg.org/loke/array/src/branch/port-mpbignum-to-wasmjs
I suppose the purpose of the
--ignore-engines
is to ignore the error that I have? Am I not adding it correctly in my groovy code?
I think I'm getting closer to understanding what fails. I checked the
tasks
variable, and it doesn't include the
NotlinNpmInstallTask
. That would explain why it never adds
--ignore-engines
.
Does anyone know where I should be checking this? Clearly the task runs, so it's defined somewhere.
I finally fixed it. The
--ignore-engines
part needed to go in the
kotlin
group in the root project. Weirdly enough, setting the node version needed to go in one of the subprojects (it doesn't appear to matter which one)