- Node.js Tutorial
- Node.js - Home
- Node.js - Introduction
- Node.js - Environment Setup
- Node.js - First Application
- Node.js - REPL Terminal
- Node.js - Command Line Options
- Node.js - Package Manager (NPM)
- Node.js - Callbacks Concept
- Node.js - Upload Files
- Node.js - Send an Email
- Node.js - Events
- Node.js - Event Loop
- Node.js - Event Emitter
- Node.js - Debugger
- Node.js - Global Objects
- Node.js - Console
- Node.js - Process
- Node.js - Scaling Application
- Node.js - Packaging
- Node.js - Express Framework
- Node.js - RESTFul API
- Node.js - Buffers
- Node.js - Streams
- Node.js - File System
- Node.js MySQL
- Node.js - MySQL Get Started
- Node.js - MySQL Create Database
- Node.js - MySQL Create Table
- Node.js - MySQL Insert Into
- Node.js - MySQL Select From
- Node.js - MySQL Where
- Node.js - MySQL Order By
- Node.js - MySQL Delete
- Node.js - MySQL Update
- Node.js - MySQL Join
- Node.js MongoDB
- Node.js - MongoDB Get Started
- Node.js - MongoDB Create Database
- Node.js - MongoDB Create Collection
- Node.js - MongoDB Insert
- Node.js - MongoDB Find
- Node.js - MongoDB Query
- Node.js - MongoDB Sort
- Node.js - MongoDB Delete
- Node.js - MongoDB Update
- Node.js - MongoDB Limit
- Node.js - MongoDB Join
- Node.js Modules
- Node.js - Modules
- Node.js - Built-in Modules
- Node.js - Utility Modules
- Node.js - Web Module
- Node.js Useful Resources
- Node.js - Quick Guide
- Node.js - Useful Resources
- Node.js - Dicussion
Node.js - path.delimiter Property
The Node.js path.delimiter property of path module shows a disparity based on the platform where it got executed. In case of Windows operating systems, it will return a semi-colon (;) and in POSIX systems it will return colon (:).
Syntax
Following is the example of the Node.js path.delimiter property −
path.delimeter
Parameters
This method does not accept any parameters.
Return value
The return value in node.js delimiter is the character or string that separates one element of a list from another. It can be used to split strings into substrings, separate words within a sentence, and even determine how data should be displayed when it is print. The possible for returned string are ';' on Windows operating systems and ':' on POSIX operating systems.
Example
In the following example, we are trying to get the platform-specific delimiter by using the Node.js path.delimiter property of OS module.
const path = require('path'); console.log(path.delimiter);
Output
If we execute the code in online compiler, it will display the results according to POSIX operating system.
Following is the output of the above program −
:
Note − If we execute the above code on Windows operating system, output will not be similar to POSIX.
When we execute the above program in WINDOWS operating system, the path.delimiter property will return semi-colon ';'.
;
Example
In the example below, we are trying to print the platform-specific delimiter in another way by using process.env.PATH property.
const path = require('path'); const process = require('process'); var delimiter = path.delimiter; console.log(process.env.PATH);
Output
Following is the output of the above program in online compiler (POSIX) −
/usr/local/bin/factor:/root/.sdkman/candidates/kotlin/current/bin:/usr/GNUstep/System/Tools:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/scriba/bin:/usr/local/smlnj/bin:/usr/local/bin/std:/usr/local/bin/extra:/usr/local/fantom/bin:/usr/local/dart/bin:/usr/libexec/sdcc:/usr/local/icon-v950/bin:/usr/local/mozart/bin:/opt/Pawn/bin:/opt/pash/Source/PashConsole/bin/Debug/:.:/root/.sdkman/candidates/kotlin/current/bin:/usr/bin:/sbin:/bin
If we compile and run the above program on WINDOWS operating system, the process.env.PATH property will print the platform specific delimiter.
C:\Python310\Scripts\;C:\Python310\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs\;C:\Users\Lenovo\AppData\Local\Microsoft\WindowsApps;C:\Users\Lenovo\AppData\Roaming\npm;C:\Users\Lenovo\AppData\Local\Programs\Microsoft VS Code\bin;
Example
Following example is another way to get the platform-specific delimiter.
const path = require('path'); const process = require('process'); var delimiter = path.delimiter; console.log(process.env.PATH.split(path.delimiter));
Output
Following is the output of the above program in online compiler (POSIX) −
[ '/usr/local/bin/factor', '/root/.sdkman/candidates/kotlin/current/bin', '/usr/GNUstep/System/Tools', '/usr/local/bin', '/usr/bin', '/usr/local/sbin', '/usr/sbin','/usr/local/scriba/bin', '/usr/local/smlnj/bin', '/usr/local/bin/std', '/usr/local/bin/extra', '/usr/local/fantom/bin', '/usr/local/dart/bin', '/usr/libexec/sdcc', '/usr/local/icon-v950/bin', '/usr/local/mozart/bin', '/opt/Pawn/bin', '/opt/pash/Source/PashConsole/bin/Debug/', '.', '/root/.sdkman/candidates/kotlin/current/bin', '/usr/bin', '/sbin', '/bin' ]
If we compile and run the above program on WINDOWS operating system, the process.env.PATH.split() method will print the platform specific delimiter in an array by splitting each path.
[ 'C:\\Python310\\Scripts\\', 'C:\\Python310\\', 'C:\\WINDOWS\\system32', 'C:\\WINDOWS', 'C:\\WINDOWS\\System32\\Wbem', 'C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\', 'C:\\WINDOWS\\System32\\OpenSSH\\', 'C:\\ProgramData\\chocolatey\\bin', 'C:\\Program Files\\nodejs\\', 'C:\\Users\\Lenovo\\AppData\\Local\\Microsoft\\WindowsApps', 'C:\\Users\\Lenovo\\AppData\\Roaming\\npm', 'C:\\Users\\Lenovo\\AppData\\Local\\Programs\\Microsoft VS Code\\bin', '' ]