I have an express nodejs app running with nodemon, however when app crashed, there is no error message logged in console:
Here is my index.js file:
/* eslint-disable */
require("babel-register");
require('./server.js');
I don't think this is a nodemon
problem because when I remove babel
, console would show error message that 'import' is not defined:
Currently for babel I use
{
"presets": ["env"],
"plugins": [
["transform-runtime", {
"helpers": false,
"polyfill": false,
"regenerator": true,
"moduleName": "babel-runtime"
}]
]
}
because of the ReferenceError: regeneratorRuntime is not defined
I tried switching node version, didn't work. Current node version v8.10.0
Would really appreciate if somebody can help me out. It is really a pain to debug without the error message.
for those who encounter the same problem, I ended up solving the problem by this:
/* eslint-disable */
require("babel-register");
try{
require('./server.js');
} catch (e) {
console.log(e)
}
If this still doesn't work, then listen to unhandledRejection
and uncaughtException
as well by:
process
.on('unhandledRejection', (reason, p) => {
console.error(reason, 'Unhandled Rejection at Promise', p);
})
.on('uncaughtException', err => {
console.error(err, 'Uncaught Exception thrown');
process.exit(1);
});