I am trying to start a mockserver-grunt using node modules. My problem is that the following error occurs:
events.js:160
throw er; // Unhandled 'error' event
^
Error: spawn java ENOENT
at exports._errnoException (util.js:1022:11)
at Process.ChildProcess._handle.onexit
(internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:609:11)
at run (bootstrap_node.js:420:7)
at startup (bootstrap_node.js:139:9)
at bootstrap_node.js:535:3
I know there a lot of questions here about this error, but I've tried a lot of answers and none of it worked. This is the first time I'm working with node and mockserver. For example I tried this answer
And my output is:
{ '0': 'java',
'1':
[ '-Dfile.encoding=UTF-8',
'-Dmockserver.logLevel=WARN',
'-jar',
[ 'mockserver-netty-3.10.6-jar-with-dependencies.jar' ],
'-serverPort',
5000 ],
'2': { stdio: [ 'ignore', 'ignore', [Object] ] } }
My mock_server.js looks like this:
var mockserver = require('mockserver-grunt');
mockserver.start_mockserver({serverPort: 5000});
and I checked, there are no other programs running on port 5000.
My package.json looks like this:
{
"name": "test",
"version": "1.0.0",
"description": "## Required environment vars",
"main": "mock_server.js",
"author": "",
"license": "ISC",
"dependencies": {
"bower": "^1.7.9",
"grunt": "1.0.1",
"grunt-cli": "1.2.0",
"mockserver-grunt": "^1.0.41"
}
I have also installed a project from scratch and the same thing happens. Would really appreciate any help. Thanks.
Ok, this is how I resolved this issue. I tried to run locally:
java -Dmockserver.logLevel=INFO -jar ~/Downloads/mockserver-netty-3.10.6-jar-with-dependencies.jar -serverPort -5000
And it seemed like:
bash: java: command not found
After I installed java, I started the server
node mock_server.js
and all went good.
So yeah, I knew this was a silly problem...