Node.js: Get directory of current file
22 June 2025 (Updated 1 July 2025)
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
console.log({ __filename, __dirname })
Tagged:
Node.js recipes