Front npm is not working with gradle

I am having problmes with sharing proyects with a front in react(node). The thing is the persone who create the project can run all perfectly, buy if you share the proyect is not the same for others. The failior is this:

Task :rm-test-front:npmInstall FAILED

Execution failed for task ':rm-test-front:npmInstall'.
> A problem occurred starting process 'command 'npm''

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

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':rm-test-front:npmInstall'.
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:207)
	at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:263)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:205)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:186)
	at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:114)
	at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
	at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:409)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:399)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:94)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:356)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'npm''
	at org.gradle.process.internal.DefaultExecHandle.execExceptionFor(DefaultExecHandle.java:241)
	at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(DefaultExecHandle.java:218)
	at org.gradle.process.internal.DefaultExecHandle.failed(DefaultExecHandle.java:372)
	at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:87)
	at org.gradle.internal.operations.CurrentBuildOperationPreservingRunnable.run(CurrentBuildOperationPreservingRunnable.java:42)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'npm'
	at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
	at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
	at org.gradle.process.internal.ExecHandleRunner.startProcess(ExecHandleRunner.java:98)
	at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:71)
	... 4 more
Caused by: java.io.IOException: Cannot run program "npm" (in directory "/home/saeron/work/cuba-rm/modules/front"): error=2, No existe el archivo o el directorio
	at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
	... 7 more
Caused by: java.io.IOException: error=2, No existe el archivo o el directorio(** file or dir doesn't exits** -traslation from spanish)
	... 8 more

I am using linux and i have node installe, actually i can run it directly from the dir. It is a thing that is ignored in .gitignore default included in the proyect. Or I need to install anything like a plugin, if it is this I would like to have it autoinstall with gradle if is posible. I been reading that it could be a gradle version, but it should be I don’t see nothing that tells me that.

This is my front gradle part:

configure(frontModule) {
    apply(plugin: 'cuba')
    apply(plugin: 'idea')
    apply(plugin: 'war')
    apply(plugin: 'maven')

    buildDir = 'build-gradle'

    def frontAppDir = "${modulePrefix}-front"

    def mainBuildDir = 'build'

   task buildAngular(type: NpmTask, dependsOn: npmInstall) {
        args = ['run', 'build']
        inputs.files fileTree('./') {
            exclude 'dist'
            exclude 'build'
        }
        outputs.dir "build"
    }

    assemble.dependsOn buildAngular

    task deploy(type: Copy, dependsOn: [assemble]) {
        from file(mainBuildDir)
        into "$cuba.tomcat.dir/webapps/$frontAppDir"
    }

    war {
        from file(mainBuildDir)
    }
}

I already spend a lot of time finding information about this without success, I will apreciate any help. I you need more information please ask.

What happens if you run “npm -version” in the terminal?

image

Works, actualy I work with diferents node proyects out of cuba-studio, and I have no problem with it.

Hi,

could you run

npm install

in the frontend directory and copy the error log here?

I have no problem with npm actuali if I do that it works , and i have no error, but the proyect can be compiled with gradle in cuba-studio. So cuba studio is unable to use npm. I forgot to said that I use linux and nvm for node, however like i said if I am the one who create the proyect i have no problem at all. The problems comes when some else create the proyect and we sincro with git.

I found the problem some files wasn’t added by default to git, I was trusting cuba studio will do it but no. Solved using git add . over front directory.