【问题标题】:Using yeoman-maven-plugin fails to execute build with npm install error使用 yeoman-maven-plugin 无法执行构建并出现 npm install 错误
【发布时间】:2013-06-11 20:07:20
【问题描述】:

我正在我的 maven webapp 上试用 yeoman-maven-plugin。当我运行“clean install -DskipTests=true -X”时,我得到以下输出。不确定发生了什么,因为“yo”目录确实存在于我的项目的根目录中。我在该目录中运行“yo angular --minsafe”来初始化应用程序。

[ERROR] Failed to execute goal com.github.trecloux:yeoman-maven-plugin:0.1:build (default) on project map-trucks: Error during : npm install: Cannot run program "npm" (in directory "/Users/patrick/IdeaProjects/XTL/map-trucks/yo"): error=2, No such file or directory -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.trecloux:yeoman-maven-plugin:0.1:build (default) on project map-trucks: Error during : npm install
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error during : npm install
    at com.axonactive.yeoman.YeomanMojo.executeCommand(YeomanMojo.java:68)
    at com.axonactive.yeoman.YeomanMojo.npmInstall(YeomanMojo.java:44)
    at com.axonactive.yeoman.YeomanMojo.execute(YeomanMojo.java:38)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 25 more
Caused by: java.io.IOException: Cannot run program "npm" (in directory "/Users/patrick/IdeaProjects/XTL/map-trucks/yo"): error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:470)
    at java.lang.Runtime.exec(Runtime.java:593)
    at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
    at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:254)
    at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:319)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
    at com.axonactive.yeoman.YeomanMojo.executeCommand(YeomanMojo.java:66)
    ... 29 more
Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:53)
    at java.lang.ProcessImpl.start(ProcessImpl.java:91)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
    ... 36 more

【问题讨论】:

  • 所以我确定它在控制台上可以正常工作,但是在 IntelliJ 中运行时失败了......
  • 帕特里克找到解决方案了吗?

标签: maven angularjs yeoman


【解决方案1】:

感谢您对 yeoman-maven-plugin 的关注。

我认为问题在于 npm 不在 IntelliJ 等 GUI 应用程序的 PATH 上。 解决方案是创建/编辑 /etc/launchd.conf 文件并添加 npm 路径(我用 brew 安装了 npm,然后我为 npm 路径和 /usr/local 添加了 /usr/local/bin /share/npm/bin 用于包 (yo, grunt, ...)

setenv PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/share/npm/bin

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-17
    • 2017-04-25
    • 2017-11-29
    • 2014-10-17
    • 2022-11-26
    • 2013-12-11
    相关资源
    最近更新 更多