gpt4 book ai didi

node.js - Maven 未能执行目标 - 无法运行程序 npm

转载 作者:可可西里 更新时间:2023-11-01 10:02:55 26 4
gpt4 key购买 nike

我使用的是 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 文件的数量也很大):

  1. 如果使用 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>
    1. 在安装 Node 的目录中重命名批处理文件,以便选择现有的 npm.cmd 文件。请参见下面的屏幕截图: rename npm batch to _npm so that npm.cmd is picked

关于node.js - Maven 未能执行目标 - 无法运行程序 npm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48156538/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com