CreateProcess error=193,%1 不是有效的 Win32 应用程序 -> [帮助 1]

12
执行maven中的exec-npm-update时,我收到以下错误信息: CreateProcess error=193,%1不是有效的Win32应用程序 -> [Help 1]
下面是pom文件的片段。
<execution>
                <id>exec-npm-update</id>
                <phase>generate-sources</phase>
                <configuration>
                  <workingDirectory>${uiResourcesDir}</workingDirectory>
                  <executable>npm</executable>
                  <arguments>
                    <argument>update</argument>
                  </arguments>
                </configuration>
                <goals>
                  <goal>exec</goal>
                </goals>
              </execution>
3个回答

22

这个问题的发生是因为我使用的Angular版本是1.5。

将可执行文件从npm改为npm.cmd解决了这个问题!

<execution>
                <id>exec-npm-update</id>
                <phase>generate-sources</phase>
                <configuration>
                  <workingDirectory>${uiResourcesDir}</workingDirectory>
                  <executable>npm.cmd</executable>
                  <arguments>
                    <argument>update</argument>
                  </arguments>
                </configuration>
                <goals>
                  <goal>exec</goal>
                </goals>
              </execution>

4
我遇到了同样的问题,就像别人回答的那样,你需要提供npm.cmd而不是只提供npm。

2
如果你的POM.xml需要跨操作系统使用,可以使用Maven配置文件。请参考:https://dev59.com/7WEh5IYBdhLWcg3wMA0t#39407412 - A. Masson

4

如果您想运行与环境无关的Shell或命令提示符命令,我是指npm.cmd(Windows)、npm.sh(Linux)等部分。

将maven-exec-plugin降级到1.4.0版本,这样您就可以简单地提及(例如):

<executable>npm</executable>
<executable>ng</executable>

我认为这是一个更好的解决方案,因为它适用于Windows和Linux,并且您可以将其用于构建管道。谢谢! - William Andrés Bernal

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接