diff --git a/lib/repl.js b/lib/repl.js index 4eac059e38..29c6d0eb49 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -281,7 +281,7 @@ function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) { // If error was SyntaxError and not JSON.parse error if (isSyntaxError(e)) { - if (cmd.trim().match(/^npm /) && !self.bufferedCommand) { + if (!self.bufferedCommand && cmd.trim().match(/^npm /)) { self.outputStream.write('npm should be run outside of the ' + 'node repl, in your normal shell.\n' + '(Press Control-D to exit.)\n'); diff --git a/test/simple/test-repl.js b/test/simple/test-repl.js index ae20a19f09..dccff9cf5d 100644 --- a/test/simple/test-repl.js +++ b/test/simple/test-repl.js @@ -150,7 +150,9 @@ function error_test() { expect: '1' }, // npm prompt error message { client: client_unix, send: 'npm install foobar', - expect: expect_npm } + expect: expect_npm }, + { client: client_unix, send: '(function () {\n\nreturn 1;\n})()', + expect: '1' } ]); }