我使用的是 Windows 7 计算机,我已获得必须运行“mvn install”才能构建应用程序的代码。当我这样做时,出现以下错误:
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (npm-install) on project [project]: Command execution failed.: Cannot run program "npm" (in directory "C:\Users\path\to\a\folder"): CreateProcess error=2, The system cannot find the file specified
应用程序本身分为几个部分,其中一个是使用 npm 的 Angular 应用程序。
我已经尝试安装 nodejs(我不是很熟悉)并将其包含在 PATH 中,但还是发生了同样的错误。 maven 不应该考虑安装它的需要吗?
如有任何关于如何解决此问题的建议,我们将不胜感激。
最佳答案
有两种方法可以纠正这个问题(如果你同时构建针对 linux 和 windows 的项目,第二种方法更可取。此外,如果 pom 文件的数量也很大):
如果使用 maven,请更改 pom 文件,请参阅 ( https://stackoverflow.com/a/40390500/4282901)
<executions> <execution> <id>npm install</id> <phase>generate-sources</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>npm.cmd</executable> <arguments> <argument>--loglevel</argument> <argument>error</argument> <argument>install</argument> </arguments> </configuration> </execution>
关于node.js - Maven 未能执行目标 - 无法运行程序 npm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48156538/