The Node.js applications generally face four types of errors:
Let's take an example to deploy standard JavaScript error - ReferenceError.
File: error_example1.js
// Throws with a ReferenceError because b is undefined
try {
  const a = 1;
  const c = a + b;
} catch (err) {
  console.log(err);
}Open Node.js command prompt and run the following code:
node error_example1.js
File: timer2.js
const fs = require('fs');
function nodeStyleCallback(err, data) {
 if (err) {
   console.error('There was an error', err);
   return;
 }
 console.log(data);
}
fs.readFile('/some/file/that/does-not-exist', nodeStyleCallback);
fs.readFile('/some/file/that/does-exist', nodeStyleCallback);Open Node.js command prompt and run the following code:
node error_example2.js
