gradle-node-plugin icon indicating copy to clipboard operation
gradle-node-plugin copied to clipboard

Upgrading node to version 12.15.0 build failure

Open induja0107 opened this issue 5 years ago • 9 comments

I tried changing node version to 12.15.0 and the build fails. 12.13.1 version of node works fine. Does the gradle-node-plugin need to be updated to support latest node version? Or is there a way i can use the 12.15.0 using the 1.1.0 of the gradle-node-plugin?

induja0107 avatar Feb 07 '20 17:02 induja0107

How did the build fail? I can't think of anything that should break

deepy avatar Feb 07 '20 18:02 deepy

it fails with latest Gradle 6.x release for every node.js version since 12.x

* What went wrong:
Execution failed for task ':nodeSetup'.
> Could not resolve all files for configuration ':detachedConfiguration1'.
   > Could not find org.nodejs:node:12.15.0.
     Searched in the following locations:
       - https://nodejs.org/dist/v12.15.0/ivy.xml
     Required by:
         project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings

but it works with latest 5.x release

Kobe avatar Feb 09 '20 20:02 Kobe

Same problem here

allnightlong avatar Feb 09 '20 21:02 allnightlong

I found a solution / workaround last night. It's using node-gradle plugin to download node/yarn/npm but on top of that gradle-node-plugin tasks.

import com.moowork.gradle.node.yarn.YarnTask

plugins {
    id("com.github.node-gradle.node") version "2.2.1"
}

repositories {
    jcenter()
}

node {
    // PLEASE use node LTS version or version with even major number
    version = "12.15.0"
    yarnVersion = "1.22.0"
    download = true
}

tasks {
    val build by registering(YarnTask::class) {
        dependsOn("yarn_install")
        args = listOf("build")
    }
}

Kobe avatar Feb 10 '20 07:02 Kobe

The problem is (or at least should be) Gradle 6.x, not the node version, you can see #315 for more information about the issue. There's multiple issues/PRs about the lack of Gradle 6 support.

The plugin you're using in the solution is the fork available at https://github.com/node-gradle/gradle-node-plugin which should work fine with all available Gradle versions ;-)

deepy avatar Feb 10 '20 08:02 deepy

@deepy I didn't find any fork hints or something like that so I assumed it's a different plugin.

Do I need import com.moowork.gradle.node.yarn.YarnTask or is there another solution?

Kobe avatar Feb 11 '20 20:02 Kobe

The fork should work fine without any workarounds, I don't think you need to import YarnTask to get this to work, simply changing to id("com.github.node-gradle.node") version "2.2.1" should be fine

deepy avatar Feb 12 '20 08:02 deepy

I don‘t think so due to you need to import YarnTasks.

Kobe avatar Mar 26 '20 06:03 Kobe

Added a fork with the fix for those using earlier gradle versions (Tested with gradle 2.11).

https://github.com/Jensen-Mourat/gradle-node-plugin

Jensen-Mourat avatar Aug 21 '21 20:08 Jensen-Mourat