Skip to content

Instantly share code, notes, and snippets.

@jrc03c
Last active September 2, 2022 15:34
Show Gist options
  • Save jrc03c/6fbccd5af3a4d1b61f12e1e620e1c01b to your computer and use it in GitHub Desktop.
Save jrc03c/6fbccd5af3a4d1b61f12e1e620e1c01b to your computer and use it in GitHub Desktop.
Create `__dirname` variable when using `import` statements in Node
const __dirname = path.resolve(
import.meta.url.replace("file://", "").split("/").slice(0, -1).join("/")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment