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

can't find nodeJS 10.15.3 ?

Open ptrtht opened this issue 6 years ago • 14 comments

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?

ptrtht avatar Mar 09 '20 20:03 ptrtht

@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

kosmoflyko avatar Mar 10 '20 07:03 kosmoflyko

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

gunslingor avatar Mar 24 '20 18:03 gunslingor

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.

deepy avatar Mar 24 '20 18:03 deepy

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?

gunslingor avatar Mar 27 '20 13:03 gunslingor

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 avatar May 08 '20 14:05 thomasmhofmann

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 avatar May 08 '20 14:05 thomasmhofmann

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

thomasmhofmann avatar May 08 '20 14:05 thomasmhofmann

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

deepy avatar May 08 '20 16:05 deepy

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.

thomasmhofmann avatar May 08 '20 17:05 thomasmhofmann

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

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

deepy avatar Aug 23 '21 05:08 deepy

@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 :(

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

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

deepy avatar Aug 23 '21 10:08 deepy

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

Jensen-Mourat avatar Aug 23 '21 15:08 Jensen-Mourat