v4.0.0 doesn't give file/line for wrong syntax.
I'm happily moving some of my stuff to ES6 but when I wrong the syntax I get SyntaxError which goes to my on( 'unhandledException' ) and I print it to get message like this. Not very helpful.
SyntaxError: Unexpected identifier
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:413:25)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/bobi/Dev/prototype-js/tests/tests.js:11:1)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
@cjihrig
I believe this should be fixed in master.
Do you know which PRs should have fixed it?
@mrahulreddy the question is whether the changes have been backported to the latest v4 or v6. v4.4.7 definitely won't work, try v4.8.0 (the latest v4), or the latest v6 or v7.
I just verified that this is addressed in node 6 (I tested w/ 6.9.5). The pretty-printed output about the syntax error is included at the top of .stack, followed by the standard name: message\nraw and dirty stack stuff.
Specifically:
In Node 4.3.0 I get:
error: A hook (`userconfig`) failed to load!
error: Error: Attempted to `require('/Users/mikermcneil/code/inabottle/config/datastores.js')`, but an error occurred:
--
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at /Users/mikermcneil/code/include-all/lib/help-include-all-sync.js:293:33
at Array.forEach (native)
at _recursivelyIncludeAll (/Users/mikermcneil/code/include-all/lib/help-include-all-sync.js:178:11)
--
Whereas in Node v6.9.5, I get:
error: A hook (`userconfig`) failed to load!
error: Error: Attempted to `require('/Users/mikermcneil/code/inabottle/config/datastores.js')`, but an error occurred:
--
/Users/mikermcneil/code/inabottle/config/datastores.js:19
adapter: 2#_ r32equire('sails-mysql'),
^
SyntaxError: Invalid or unexpected token
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at /Users/mikermcneil/code/include-all/lib/help-include-all-sync.js:293:33
at Array.forEach (native)
--
Make sure that you have installed latest LTS version of nodeJS from https://nodejs.org/ As described in package.json ` "engines": {
"node": ">=6"
}`