在与许多专家交谈并阅读了大量论坛帖子后,以下是建议的“解决方法”。许多人使用这种变通方法。我希望你有一个比这个更好的解决方案。至少,这种变通方法是有效的。
按照解决方法,在Maven中构建Angular可以如下:首先清除工作区,特别是删除node_modules文件夹和package-lock.json文件。然后启动npm安装和构建操作。
如果您在创建第一个构建之后很匆忙,只需添加属性“maven.exec.skip”,并使用-pmaven.exec.skip=true启动maven。然后跳过清洗和npm安装步骤;-)
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>npm clear workspace</id>
<goals>
<goal>exec</goal>
</goals>
<phase>initialize</phase>
<configuration>
<skip>${maven.exec.skip}</skip>
<executable>rm</executable>
<arguments>
<argument>-rf</argument>
<argument>node_modules</argument>
<argument>package-lock.json</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>exec</goal>
</goals>
<phase>initialize</phase>
<configuration>
<skip>${maven.exec.skip}</skip>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>build Angular production code</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>build</argument>
<!--<argument>--prod</argument>-->
</arguments>
</configuration>
</execution>
</executions>
</plugin>