If you’re exporting single functions from CommonJS modules in Node.js, improve your stack traces and make debugging easier by naming those functions:
module.exports = function anotherFunction() {
// ...
};
![Screenshot of CommonJS module in Node.js with anonymous functions which result in a less clear error stack trace](https://simonplend.com/wp-content/uploads/2021/03/stack-trace-anonymous.png)
![Screenshot of CommonJS module in Node.js with a named function which results in a clearer error stack trace](https://simonplend.com/wp-content/uploads/2021/03/stack-trace-named.png)
If you’re exporting single functions from CommonJS modules in Node.js, improve your stack traces and make debugging easier by naming those functions:
module.exports = function anotherFunction() {
// ...
};