node-gradle / gradle-node-plugin

Gradle plugin for integrating NodeJS in your build. :rocket:
Apache License 2.0
599 stars 117 forks source link

Cannot set the value of read-only property 'version' for task ':npmSetup' of type #264

Open xavierdevairakkam opened 1 year ago

xavierdevairakkam commented 1 year ago

`node { // Versions of node , npm version = "14.15.1" npmVersion = "6.14.8"

    // Enabled the automatic download. False is the default (for now).
    download = true

}`

xavierdevairakkam commented 1 year ago

The build is working fine with 2x versions (2.2.4) without any issues. But when I run the build with any of the 3x versions, I'm getting the above error.

The gradle version is 7.0 and JDK version is 8. I hope these are sufficient to run the 3x version as per the document.

cdietrich commented 1 year ago

@xavierdevairakkam can you provide a complete reproducer? are you using kotlin dsl? then i would expect

node {
    version.set("16.14.0")

or the like

xavierdevairakkam commented 1 year ago

It is groovy dsl @cdietrich . Here is my sample build.gradle content for your reference

plugins {
        id "com.github.node-gradle.node" version "3.5.1"
}

node {
    // Versions of node , npm
    version = "14.15.1"
    npmVersion = "6.14.8"

    // Enabled the automatic download. False is the default (for now).
    download = true
}

npm_run_build {
    inputs.file 'package.json'
}

task cleanDist(type: NpmTask) {
    args = ['run', 'clean']
}

assemble.dependsOn npm_run_build

task test(type: NpmTask) {
        dependsOn assemble
    args = ['run', 'test']
}

task build(type: NpmTask) {
    dependsOn clean
    dependsOn cleanDist
        dependsOn test
    args = ['run', 'build']
}

wrapper {
        gradleVersion = '7.0'
}
cdietrich commented 1 year ago

i still cannot reproduce your problem with that snippet.

xavierdevairakkam commented 1 year ago

Is it running fine for you? @cdietrich

cdietrich commented 1 year ago

i had to add a clean task and an assembe task, and a package json but yes