Ach*_*yut 13 maven node.js gruntjs
当我遍历到src/main/app/我拥有package.JSON&gruntfile的文件夹结构时,我能够运行npm install并grunt命令.但是当我尝试mvn jetty:run在POM文件存在时运行项目的根文件夹中的属性文件时,它会抛出错误,它无法npm install在文件夹结构中运行src/main/app/.
这是确切的错误:
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (n
pminstall) on project my-abc-web: Command execution failed. Cannot
run program "npm" (in directory "C:\Users\Achyut_J01\Documents\GitHub\infras\my-abc\my-abc-web\src\main\app"): CreatePro
cess error=2, The system cannot find the file specified -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
这是一台Windows机器.
Mos*_*roy 11
我使用此解决方法来实现跨平台的Maven构建:将npm可执行文件名称声明为Maven变量,并在Windows上运行时使用Maven过滤器修改此可执行文件名称.
它可以用于Grunt,Bower等.
如果你使用exec-maven-plugin> = 1.6.0(感谢Manmay的评论中的信息),这个解决方法就不再需要了:这是这个插件的一个bug(参见https://github.com/mojohaus/) exec-maven-plugin/issues/42),已在1.6.0中修复(参见https://github.com/mojohaus/exec-maven-plugin/pull/46)
<properties>
<npm.executable>npm</npm.executable>
</properties>
(...)
<build>
<plugins>
(...)
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<id>exec-npm</id>
<phase>process-resources</phase>
<configuration>
<executable>${npm.executable}</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
(...)
</plugins>
</build>
<profiles>
<profile>
<id>platform-windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<!-- Override the executable names for Windows -->
<npm.executable>npm.cmd</npm.executable>
<grunt.executable>grunt.cmd</grunt.executable>
<bower.executable>bower.cmd</bower.executable>
</properties>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
26461 次 |
| 最近记录: |