Components and utilities for the modern web
Node

dirname

dirname is a utility that lets you get the directory of the current file easily when you use ESM with Node. If you are using CJS, just use __dirname.

Installation

First, make sure you install Splendid UI.

npm install splendid-ui

Then import dirname into your project.

import { dirname } from 'splendid-ui/node'

Usage

Just pass import.meta.url into dirname and you will get the directory.

const __dirname = dirname(import.meta.url)

Like what you're seeing?

I'm on a quest to make web development extremely easy — by building components and utilities that will help all of us build better apps at a much faster pace.

I'd like to send you an update when I release something new in Splendid UI. If you want to be updated, please leave your email address below.

Powered by Buttondown