Const in a try catch pattern

It’s annoying to declare variables outside the try/catch block to use them on the outer scopes.

Use .catch instead on async tasks

You can skip the whole block:

async function main() {
  const result = await asyncTask().catch(error => console.error(error));
}

On an error, result is undefined.

Source: Javascript set const variable inside of a try block

Wrap trycatch into function

const configPath = (function() {
  try {
    return path.resolve(process.cwd(), config);
  } catch (error) {
    //.....
  }
})()

Source: Javascript set const variable inside of a try block