Anthony Fu 8/30/2021

Isomorphic `__dirname`

Read Original

This technical article explains how to create an isomorphic __dirname variable that works in both ESM (where __dirname is not available) and CommonJS modules. It provides a code snippet using Node.js's path and url modules, specifically useful for developers writing TypeScript code transpiled to both formats with tools like tsup.

Isomorphic `__dirname`

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week