无法运行程序“npm”在目录中 [英] Cannot run program "npm" in directory

查看:1830
本文介绍了无法运行程序“npm”在目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我遍历到 src / main / app / 文件夹结构时,我有 package.JSON &安培; gruntfile,我可以运行 npm install grunt 命令。但是当我尝试运行 mvn jetty:run 并且在POM文件存在时项目的根文件夹中有一个属性文件时,它会抛出无法运行的错误 npm install 在文件夹结构中 src / main / app /



这是确切的错误:

  [INFO] ------------- -------------------------------------------------- --------- 
[错误]无法执行目标org.codehaus.mojo:项目my-abc上的exec-maven-plugin:1.2.1:exec(n
pminstall) -web:命令执行失败。无法
运行程序npm(在目录C:\ Users \Achyut_J01\Documents\GitHub\infras\my-abc\my-abc-web\src\main\\ \\ app):CreatePro
cess error = 2,系统找不到指定的文件 - > [帮助1]

这是一台Windows机器。

解决方案

显然你是在Windows系统上。 npm是批处理文件,不是可执行文件。有问题从maven exec插件运行批处理文件。您可能想要探索链接中建议的解决方法,如


  • 将.bat脚本解构为其实际命令

  • 使用cmd.exe并传递节点作为参数 - 引用


When i am traversing the to src/main/app/ folder structure where i have the package.JSON & gruntfile, i am able to run npm install and grunt command. But when i am trying to run the mvn jetty:run and a property file in the root folder of the project when POM file is present, it is throwing error that it cannot run npm install in the folder structure src/main/app/.

This is the exact error:

[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]

It's a Windows Machine.

解决方案

Evidently you are on a Windows system. npm is a batch file and not an executable. There are issues running a batch file from maven exec plugin. You may want to explore the workaround suggested in the link, like

  • deconstruct the .bat script into its actual commands
  • use cmd.exe and pass node as parameter - refer to this.

这篇关于无法运行程序“npm”在目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆