exec-maven-plugin plugin error

旧城冷巷雨未停 提交于 2020-01-16 07:58:09

问题


I use the exec-maven-plugin as follow

<plugin>
          <artifactId>exec-maven-plugin</artifactId>
          <groupId>org.codehaus.mojo</groupId>
          <version>1.6.0</version>
          <executions>
            <execution>
              <id>npm install</id>
              <goals>
                <goal>exec</goal>
              </goals>
              <phase>generate-sources</phase>
              <configuration>
                <executable>${npm.executable}</executable>
                <arguments>
                  <argument>install</argument>
                </arguments>
                <workingDirectory>${basedir}/target/angular5/tourism</workingDirectory>
                <target>
                  <echo message="Npm install" />
                </target>
              </configuration>
            </execution>
          </executions>
        </plugin>

I have the following error

 java.io.IOException: Cannot run program "npm" (in directory "/Users/admin/Application-Marwen/workspace/Tourism/Tourism-Web/target/angular5/tourism"): error=2, No such file or directory

However the directory "/Users/admin/Application-Marwen/workspace/Tourism/Tourism-Web/target/angular5/tourism" exists and the command npm install works in this directory in the console. I have the Apache Maven 3.5.4 installed and use eclipse


回答1:


First, you should edit your question as I mentionned in comments below.

Then, I think you misunderstood the error. In fact, the error indicates that npm is not found inside your directory "/Users/admin/Application-Marwen/workspace/Tourism/Tourism-Web/target/angular5/tourism.

And this is normal. npm is in your PATH that's why you can run npm install successfully.

I recommand you to use a Maven plugin for npm commands:

  • frontend-maven-plugin
  • npm-maven-plugin



回答2:


Adding -PlocalNoDeploy as part of your mvn command might resolve this issue.



来源:https://stackoverflow.com/questions/51384032/exec-maven-plugin-plugin-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!