# chdir > Change the current working directory.
## Usage ```javascript var chdir = require( '@stdlib/process/chdir' ); ``` #### chdir( path ) Changes the current working directory to the specified `path`. ```javascript var err = chdir( '/foo/bar' ); ``` If the function encounters an error when attempting to change the working directory, the function returns an `error`; otherwise, the function returns `null`.
## Notes - See [chdir(2)][chdir].
## Examples ```javascript var cwd = require( '@stdlib/process/cwd' ); var chdir = require( '@stdlib/process/chdir' ); // Print the current working directory: var dir = cwd(); console.log( dir ); // Change the current working directory to the directory of this file: var err = chdir( __dirname ); if ( err ) { console.error( err.message ); } // Print the current working directory: console.log( cwd() ); // Change the current working directory back to the original directory: err = chdir( dir ); if ( err ) { console.error( err.message ); } // Print the current working directory: console.log( cwd() ); ```