---
title: "Discussion on \"Alternative for __dirname in Node when using ECMAScript modules\" | Hashnode"
description: "Discussion on \"Alternative for __dirname in Node when using ECMAScript modules\". As I searched the Stack Overflow I came across several solutions that suggest using import.meta.url with fileURLToPath, however what was not mentioned is that the purpose of fileURLToPath is beyond \"resolving\" URLs with file://, as the documentation ..."
url: "https://hashnode.com/posts/alternative-for-dirname-in-node-when-using-ecmascript-modules/60a1e764b66a0b15ebfca40b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Alternative for \_\_dirname in Node when using ECMAScript modules](https://web-developer.hashnode.dev/alternative-for-dirname-in-node-when-using-ecmascript-modules?utm_source=hashnode&utm_medium=feed)

As I searched the Stack Overflow I came across several solutions that suggest using import.meta.url with fileURLToPath, however what was not mentioned is that the purpose of fileURLToPath is beyond "resolving" URLs with file://, as the documentation ...

May 17, 2021 · 2 min read · web-developer.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#nodejs](https://hashnode.com/tag/nodejs)

## Written by

[Guilherme Nascimento](https://hashnode.com/@brcontainer)

@brcontainer

  
[View profile](https://hashnode.com/@brcontainer)

php, javascript, java, go, python

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
