Skip to content

Commit 67bca8f

Browse files
bweston92alexeagle
authored andcommitted
fix(builtin): reformat the error message for Node loader.js
The format of Node's own error from loader.js is https://github.com/nodejs/node/blob/a49b20d3245dd2a4d890e28582f3c013c07c3136/lib/internal/modules/cjs/loader.js#L264
1 parent d4686a8 commit 67bca8f

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

internal/node/node_loader.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,15 @@ module.constructor._resolveFilename = function(request, parent, isMain, options)
468468
}
469469

470470
const error = new Error(
471-
`${TARGET} cannot find module '${request}' required by '${parentFilename}'\n looked in:\n` +
472-
failedResolutions.map(r => ` ${r}`).join('\n') + '\n');
471+
`Cannot find module '${request}'. ` +
472+
'Please verify that the package.json has a valid "main" entry'
473+
);
473474
error.code = 'MODULE_NOT_FOUND';
475+
// todo - error.path = ?;
476+
error.requestPath = parentFilename;
477+
error.bazelTarget = TARGET;
478+
error.failedResolutions = failedResolutions;
479+
474480
throw error;
475481
}
476482

0 commit comments

Comments
 (0)