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
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]
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!
Another workaround, in case anyone else is stuck on an older JDK like me, is to run
from exec-maven-plugin.
Its amazing how version of java can affect the behavior of maven.
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).
I simple updated to java1.7_40 and everything went perfectly fine.