来自Maven的节点npm在项目目录中看起来为npm-cli.js [英] node npm from maven looks npm-cli.js in project directory
问题描述
我正在使用exec-maven-plugin从maven运行'npm install'.它失败并显示以下错误:
I'm running 'npm install' from maven using exec-maven-plugin. And it fails with such error:
module.js:340
throw err;
^
Error: Cannot find module 'D:\projects\git\code\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
显然,在项目路径下没有npm-cli,它在安装nodejs的全局路径中.
obviously there is no npm-cli under project path, it's in the global path where nodejs is installed.
因此整个构建都因状态失败
So the whole build is failed with status
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (npm) on project myproject: Command execution failed. Process exited with an error: 8 (Exit value: 8) -> [Help 1]
在控制台下执行"npm install"的另一个有趣的事情是运行得很好.仅当我从Maven运行它时,问题才会发生.
Another interesting thing that 'npm install' under console is run perfectly fine. Problem only occurs when I run it from maven.
任何想法将不胜感激!
Any thoughts would be appreciated!
推荐答案
java版本如何影响maven的行为令人惊奇.
Its amazing how version of java can affect the behavior of maven.
问题出在使用java1.7_25,java尝试从maven运行exec任务时,它破坏了〜dp0路径(正在运行的任务的目标路径).
The problem was in using java1.7_25,java when it tried to run exec task from maven it broke the ~dp0 path(the target path of the task which is run).
我简单地更新到java1.7_40,一切都很好.
I simple updated to java1.7_40 and everything went perfectly fine.
这篇关于来自Maven的节点npm在项目目录中看起来为npm-cli.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!