无法在目录中运行程序“npm”
当我遍历到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]
这是一个Windows机器。
显然你在Windows系统上。 npm是一个batch file,而不是一个可执行文件。 从maven exec插件运行batch file有问题 。 您可能想要探索链接中build议的解决方法,如
- 将.bat脚本解构成其实际的命令
- 使用cmd.exe并传递节点作为参数 – 参考这个 。
我使用这种解决方法来创build一个跨平台的Maven构build:将npm可执行文件的名称声明为Mavenvariables,并在Windows上运行时使用Mavenfilter来修改此可执行文件的名称。
它可以为Grunt,Bower等工作。
<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>
在Windows平台中,使用npm.cmd来replacenpm
- npm仍然安装软件包到'/ usr / local / Cellar / node / …',尽pipe我已经卸载了Homebrew的版本节点
- 对于某些Windows用户,“grunt”不被识别为内部或外部命令
- grunt.js(一个node.js构build工具)不会创build目录或文件。 是否与权限相关?
- 谷歌地图不在帕格/翡翠工作
- Mac npm与ENOENT错误
- 在客户端不使用npm部署node.js项目
- 咕噜+ mochaTest:更改工作目录?
- Microsoft Azure持续集成 – 使用Grunt“编译”步骤的NodeJs解决scheme
- AWS Elastic Beanstalk运行Grunt任务