diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index b09e3cceb55120..a002efa175a708 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -97,7 +97,7 @@ function enrichCJSError(err) { usage. However, some cases are not matching, cases like import statement after a comment block and/or after a variable definition. */ - if (err.message.startsWith('Unexpected token export') || + if (err.message.startsWith('Unexpected token \'export\'') || (/^\s*import(?=[ {'"*])\s*(?![ (])/).test(lineWithErr)) { process.emitWarning( 'To load an ES module, set "type": "module" in the package.json or use ' + diff --git a/test/parallel/test-v8-flags.js b/test/parallel/test-v8-flags.js index 50d7047a5ddfa9..e476c5e3886661 100644 --- a/test/parallel/test-v8-flags.js +++ b/test/parallel/test-v8-flags.js @@ -13,6 +13,6 @@ assert(vm.runInThisContext('%_IsSmi(43)')); v8.setFlagsFromString('--noallow_natives_syntax'); assert.throws(function() { eval('%_IsSmi(44)'); }, - /^SyntaxError: Unexpected token %$/); + /^SyntaxError: Unexpected token '%'$/); assert.throws(function() { vm.runInThisContext('%_IsSmi(45)'); }, - /^SyntaxError: Unexpected token %$/); + /^SyntaxError: Unexpected token '%'$/); diff --git a/test/parallel/test-vm-basic.js b/test/parallel/test-vm-basic.js index 29e2a8b5251934..69fd859b028815 100644 --- a/test/parallel/test-vm-basic.js +++ b/test/parallel/test-vm-basic.js @@ -152,7 +152,7 @@ const vm = require('vm'); ); }, { type: SyntaxError, - message: 'Unexpected token }' + message: "Unexpected token '}'" }); // Tests for failed argument validation