From 58902725387a87e363410519f9afb865c2c3300d Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 21 Nov 2010 13:58:47 -0800 Subject: [PATCH] Print friendly error message when main module is ENOENT --- src/node.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/node.js b/src/node.js index 31e7da4fa3c..aba2eb70445 100644 --- a/src/node.js +++ b/src/node.js @@ -348,7 +348,17 @@ var module = (function () { exports.runMain = function () { // Load the main module--the command line argument. process.mainModule = new Module("."); - process.mainModule.load(process.argv[1]); + try { + process.mainModule.load(process.argv[1]); + } catch (e) { + if (!constants) constants = process.binding("constants"); + if (e.errno == constants.ENOENT) { + console.error("Cannot load '%s'", process.argv[1]); + process.exit(1); + } else { + throw e; + } + } }; return exports;