Node.js path.delimiter Property
The path.delimiter property is an inbuilt application programming interface of the path module which is used to get platform-specific path delimiter.
Syntax:
path.delimiter;
Return Value: This property returns a string that represents platform specific path delimiter. The returned value is : for POSIX and ; for Windows.
Below examples illustrate the use of path.delimiter in Node.js:
Example 1:
const path = require( 'path' );
console.log(path.delimiter);
|
Output:
;
Example 2:
const path = require( 'path' );
const process = require( 'process' );
var delimiter = path.delimiter;
console.log(process.env.PATH);
console.log(process.env.PATH.split(path.delimiter));
|
Output:
C:\wamp64\bin\php\php7.3.1\ext\ImageMagick;C:\Program Files (x86)\Common
Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;
C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Windows\System32\OpenSSH\;D:\programfiles\Git\cmd;
D:\programfiles\Cmake\bin;
C:\Program
Files\nodejs\;C:\Users\gekcho\AppData\Local\Microsoft\WindowsApps;
C:\Users\gekcho\AppData\Roaming\npm
[ 'C:\\wamp64\\bin\\php\\php7.3.1\\ext\\ImageMagick',
'C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath',
'C:\\Windows\\system32',
'C:\\Windows',
'C:\\Windows\\System32\\Wbem',
'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\',
'C:\\Windows\\System32\\OpenSSH\\',
'D:\\programfiles\\Git\\cmd',
'D:\\programfiles\\Cmake\\bin',
'C:\\Program Files\\nodejs\\',
'C:\\Users\\gekcho\\AppData\\Local\\Microsoft\\WindowsApps',
'C:\\Users\\gekcho\\AppData\\Roaming\\npm' ]
Note: The above program will compile and run by using the node filename.js
command.
Reference: https://nodejs.org/api/path.html#path_path_delimiter
Last Updated :
11 Oct, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...