gpt4 book ai didi

javascript - frontend-maven-plugin 可以使用 node,npm 已经安装了吗?

转载 作者:数据小太阳 更新时间:2023-10-29 04:59:58 25 4
gpt4 key购买 nike

我是 maven 和 frontend-maven-plugin 的新手。我知道我们可以将此代码添加到 pom.xml 以运行 grunt,例如:

         <plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<!-- NB! Set <version> to the latest released version of frontend-maven-plugin, like in README.md -->
<version>@project.version@</version>

<executions>

<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v5.3.0</nodeVersion>
<npmVersion>3.3.12</npmVersion>
</configuration>
</execution>

<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>install</arguments>
</configuration>
</execution>

<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>

<execution>
<id>grunt build</id>
<goals>
<goal>grunt</goal>
</goals>
<configuration>
<arguments>--no-color</arguments>
</configuration>
</execution>
</executions>
</plugin>

我实际上在我的服务器上安装了 node 和 npm例如:node安装在/opt/app/trss/nodejs下,npm安装在/opt/app/trss/nodejs/npm下这个pom.xml如何使用我服务器上安装的node,npm?谢谢

最佳答案

该插件被设计为使用本地安装的 Node 。使用全局安装版本已 requested before但开发者的立场是 Node 不占用太多空间,只有丢失才会下载。

本地安装 node 允许尚未全局安装 node 或正在使用不同版本的开发人员构建项目,而无需执行比 mvn clean install 更复杂的操作。

您可以使用 exec plugin运行全局安装的 npm 版本,然后运行 ​​grunt。像这样的东西:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<id>run-npm-install</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>run-grunt</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>grunt</executable>
<arguments>
<argument>--no-color</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>

关于javascript - frontend-maven-plugin 可以使用 node,npm 已经安装了吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37329708/

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