srs / gradle-node-plugin

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

can't find nodeJS 10.15.3 ? #368

Open ptrtht opened 4 years ago

ptrtht commented 4 years ago

I started a new gradle app, in which I want to do reactjs FE. I am unable to run my build due to the following error:

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

My build.gradle looks like this:


plugins {
    id 'org.springframework.boot' version '2.2.5.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
    id "com.moowork.node" version "1.3.1"
}

group = 'com.traveling.owl'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

node {
    download = true
    workDir = file("${project.projectDir}/src/main/reactjs/nodejs")
    npmWorkDir = file("${project.projectDir}/src/main/reactjs/npm")
    nodeModulesDir = file("${project.projectDir}/src/main/reactjs")
}

task npmInstallDependencies(type: NpmTask) {
    dependsOn 'npmSetup'
    execOverrides {
        it.ignoreExitValue = true
        it.workingDir = 'src/main/reactjs'
    }
    args = ['install']
}

task npmBuild(type: NpmTask) {
    dependsOn 'npmInstallDependencies'
    execOverrides {
        it.workingDir = 'src/main/reactjs'
    }
    args = ['run', 'build']
}

task copyBuild(type: Copy) {
    dependsOn 'npmBuild'
    from "$projectDir/src/main/reactjs/build"
    into "$buildDir/src/main/resources/static"
}

processResources {
    dependsOn 'copyBuild'
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-rest'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

test {
    useJUnitPlatform()
}

I only have nodejs v10.15.3 installed. What can be the problem in my case?

kosmoflyko commented 4 years ago

@qty0 I have similar issue for any node version with this plugin now. I see that this plugin no supported now, but many documents has link to this plugin. As workaround you can use new version https://github.com/node-gradle/gradle-node-plugin/blob/master/docs/node.md

gunslingor commented 4 years ago

I'm having lots of similar issues for days now. it has something to do with mooworks conflicts I think., or kotlinNodeJsSetup or resources folders. No matter what I do I can't get jsBrowserTests to run with my stuff. But everything else runs fine. Days wasted on this, discussion link in slack might work for details of troubleshooting:

https://kotlinlang.slack.com/archives/C3PQML5NU/p1585030653200800

deepy commented 4 years ago

I'm having lots of similar issues for days now. it has something to do with mooworks conflicts I think., or kotlinNodeJsSetup or resources folders. No matter what I do I can't get jsBrowserTests to run with my stuff. But everything else runs fine. Days wasted on this, discussion link in slack might work for details of troubleshooting:

Either you'll have to downgrade Gradle far back or switch to a fork.

gunslingor commented 4 years ago

For me, problem was solved in the slack thread I posted above. How or why this solved it I do not know exactly, but it feels like its directly injecting my js dependancy into karma thru webpack.config external file or something like that.

The solution was to create a folder and file on the root directory called karma.config.d/config.js with the following in it: config.files.unshift(require('path').resolve(__dirname, "../../../processedResources/frontend/main/libs/js/[YOUR JS FILE NAME].min.js"));

Not a fan of having this extra config on the root level and personally I don't understand what this TRUELY is or why I can't configure it from gradle multiplatform... I mean a goal of gradle is to be able to configure everything with it right?

thomasmhofmann commented 4 years ago

I think this is related to changes in Gradle 6: https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:supported_metadata_sources

It is looking for an ivy.xml file that is not published / available.

thomasmhofmann commented 4 years ago

This would probably need to change here: https://github.com/srs/gradle-node-plugin/blob/a987e56f105c7cf706361c6c70c517af17ff459c/src/main/groovy/com/moowork/gradle/node/task/SetupTask.groovy#L180

metadataSources { ivyDesriptor() artifact() }

thomasmhofmann commented 4 years ago

Actually this seems already to be know: https://github.com/srs/gradle-node-plugin/pull/349#issuecomment-540650222

deepy commented 4 years ago

There's an actively maintained fork at https://github.com/node-gradle/gradle-node-plugin But we've dropped the grunt/gulp support in favor of npx

thomasmhofmann commented 4 years ago

Thanks I already switched to that fork. I wasn't aware this not longer being maintained. Your fork works good with Gradle 6 so thanks a lot.

Jensen-Mourat commented 2 years ago

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

deepy commented 2 years ago

If you're still on gradle 2 you have great incentives to upgrade, it's a pretty painless process and gradle gets much faster

Jensen-Mourat commented 2 years ago

@deepy I would love to upgrade but for some reasons the monolith of a framework we are using supports only gradle 2.11. Sadly not everyone gets to use the new and shiny version of a program :(

deepy commented 2 years ago

That kinda makes me curious about your fork as this issue comes with gradle 4 or 3

Jensen-Mourat commented 2 years ago

I bypassed the way node js was meant to be downloaded using gradle here:

 this.repo = this.project.repositories.ivy {
            url distUrl
            layout 'pattern', {
                artifact 'v[revision]/[artifact](-v[revision]-[classifier]).[ext]'
                ivy 'v[revision]/ivy.xml'
            }
        }

and simply wrote some download logic which gets the correct node version respective of the os and arc