Node.js path.dirname() Method

❮ Path Module


Example

Get the directories from a file path:

var path = require('path');

var directories = path.dirname('/Users/Refsnes/demo_path.js');
console.log(directories);
Run example »

Definition and Usage

The path.dirname() method returns the directories of a file path.


Syntax

path.dirname(path);

Parameter Values

Parameter Description
path Required. The file path to search in

Technical Details

Return Value: The directories, as a String
Node.js Version: 0.1.16

❮ Path Module

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.