Home >Web Front-end >JS Tutorial >Instructions for using the path.delimiter method in node.js_node.js

Instructions for using the path.delimiter method in node.js_node.js

WBOY
WBOYOriginal
2016-05-16 16:28:092077browse

Method description:

The method will return the real path of the platform. Multiple paths are separated by ":" or ";".

Grammar:

Copy code The code is as follows:

path.delimiter

Since this method belongs to the path module, the path module needs to be introduced before use (var path= require(“path”) )

Receive parameters:

None

Example:

Copy code The code is as follows:

//Example on *nix systems:

console.log(process.env.PATH)
// '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin'

process.env.PATH.split(path.delimiter)
// returns
['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin']

Example on windows:

console.log(process.env.PATH)
// 'C:Windowssystem32;C:Windows;C:Program Filesnodejs'

process.env.PATH.split(path.delimiter)
// returns
['C:Windowssystem32', 'C:Windows', 'C:Program Filesnodejs']
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn