I execute mvn clean install
inside a docker container from image maven:3-alpine
to build the application. In the pom.xml I make use of the frontend-maven-plugin
because I need to install node
and npm
and then run npm install
to build the frontend (angular).
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.9.1</version>
<configuration>
<nodeVersion>v12.16.1</nodeVersion>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>install</arguments>
<installDirectory>./</installDirectory>
</configuration>
</execution>
<execution>
<id>ng build</id>
<goals>
<goal>npm</goal>
</goals>
<phase>compile</phase>
<configuration>
<arguments>run-script build</arguments>
</configuration>
</execution>
</executions>
</plugin>
Node and npm will be installed correctly but when it runs npm install
it returns an error: Failed to run task: 'npm install' failed. java.io.IOException: Cannot run program "/var/lib/jenkins/workspace/myProject/node/node" (in directory "/var/lib/jenkins/workspace/myProject"): error=2, No such file or directory -> [Help 1]
If I enter into the container (docker exec) and try to run manually npm install it gives me again the same error. When I check if node is correctly installed then I see the file /var/lib/jenkins/workspace/myProject/node/node
is there but when I try to run node from inside the /node directory myself, let's say node -v
it says me again No such file or directory
. I don't understand why it is happening, because node is there!! The current user has also the right to execute this file.
I did some search about the problem, some people say that installing node on ubuntu in this way is not the correct way but that happens only in my container. If I try the same on my local machine (it is also an ubuntu) then node works.