util.getSystemErrorMessage(err)


返回来自 Node.js API 的数字错误代码的字符串消息。错误代码和字符串消息之间的映射取决于平台。

¥Returns the string message for a numeric error code that comes from a Node.js API. The mapping between error codes and string messages is platform-dependent.

fs.access('file/that/does/not/exist', (err) => {
  const message = util.getSystemErrorMessage(err.errno);
  console.error(message);  // No such file or directory
});