eirslett / frontend-maven-plugin

"Maven-node-grunt-gulp-npm-node-plugin to end all maven-node-grunt-gulp-npm-plugins." A Maven plugin that downloads/installs Node and NPM locally, runs NPM install, Grunt, Gulp and/or Karma.
Apache License 2.0
4.2k stars 867 forks source link

Cannot run program "npx" error=2, No such file or directory #1082

Open debraj-manna opened 1 year ago

debraj-manna commented 1 year ago

I am trying to use frontend-maven-plugin 1.12.1 with maven 3.8.4. My pom configuration looks like below. But on doing mvn clean install I am getting the below error

Error:  Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.1.0:exec (validate api specs) on project master: Command execution failed.: Cannot run program "npx" (in directory "/opt/actions-runner/_work/spotnana/spotnana/src/java/obt/master/target"): error=2, No such file or directory -> [Help 1]
Error:  

Can someone let me know what I am doing wrong?

<plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>1.12.1</version>
        <executions>
          <execution>
            <id>install node and npm</id>
            <goals>
              <goal>install-node-and-npm</goal>
            </goals>
            <!-- optional: default phase is "generate-resources" -->
            <phase>initialize</phase>
            <configuration>
              <installDirectory>target</installDirectory>
              <nodeVersion>v19.6.0</nodeVersion>
              <npmVersion>9.5.0</npmVersion>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
          <execution>
            <id>install openapi merger</id>
            <goals>
              <goal>exec</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <executable>${project.basedir}/target/node/npm</executable>
              <workingDirectory>${project.basedir}/target/node</workingDirectory>
              <arguments>
                <argument>install</argument>
                <argument>openapi-merger</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>generate internal api spec</id>
            <goals>
              <goal>exec</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <executable>${project.basedir}/target/node/node_modules/.bin/openapi-merger
              </executable>
              <workingDirectory>${project.basedir}/target/node</workingDirectory>
              <environmentVariables>
                <PATH>${env.PATH}:${project.basedir}/target/node</PATH>
              </environmentVariables>
              <arguments>
                <argument>-i</argument>
                <argument>${project.basedir}/src/main/resources/yaml/apis/api/Api.yaml
                </argument>
                <argument>-o</argument>
                <argument>${project.basedir}/src/main/resources/api/InternalApiSpec.yaml</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>validate api specs</id>
            <goals>
              <goal>exec</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <executable>npx</executable>
              <workingDirectory>${project.basedir}/target</workingDirectory>
              <environmentVariables>
                <PATH>${env.PATH}:${project.basedir}/target/node</PATH>
              </environmentVariables>
              <arguments>
                <argument>@redocly/cli@latest</argument>
                <argument>lint</argument>
                <argument>${project.basedir}/src/main/resources/api/PolicyApi.yaml</argument>
                <argument>${project.basedir}/src/main/resources/api/CompanyApi.yaml</argument>
                <argument>${project.basedir}/src/main/resources/api/UsersApi.yaml</argument>
                <argument>${project.basedir}/src/main/resources/api/TripApi.yaml</argument>
                <argument>${project.basedir}/src/main/resources/api/InternalApiSpec.yaml</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>