# How to get the current folder in Node

> Learn how to get the current folder in Node.js and understand the difference between ./, __dirname, and process.cwd() when referencing the filesystem.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2018-08-09 | Topics: [Node.js](https://flaviocopes.com/tags/node/) | Canonical: https://flaviocopes.com/node-get-current-folder/

There are basically two ways to reference the current folder in a [Node.js](https://flaviocopes.com/nodejs/) script:

- `./`
- `__dirname`

> Along with `./`, there is `../`, which points to the parent folder. They behave in the same way.

There is a big difference between the two.

Using `__dirname` in a Node script will return the path of the folder **where the current [JavaScript](https://flaviocopes.com/javascript/) file resides**.

Using `./` will give you the **current working directory**. It will return the same result as calling [`process.cwd()`](https://nodejs.org/api/process.html#process_process_cwd).

Initially the current working directory is the path of the folder where you ran the node command, but that can be changed during the execution of your script, by using the [`process.chdir()`](https://nodejs.org/api/process.html#process_process_chdir_directory) API.

There is just one place where `./` refers to the current file path, and it's in a `require()` call. In there, `./` (for convenience) will always refer to the JavaScript file path, letting you import other modules based on the folder structure.
