Node.js 경로 모듈

❮ 내장 모듈


예시

파일 경로에서 파일 이름 추출:

var path = require('path');
var filename = path.basename('/Users/Refsnes/demo_path.js');
console.log(filename);

정의 및 사용

경로 모듈은 디렉토리 및 파일 경로로 작업하는 방법을 제공합니다.


통사론

애플리케이션에 Path 모듈을 포함하기 위한 구문:

var path = require('path');

경로 속성 및 메서드

Method Description
basename() Returns the last part of a path
delimiter Returns the delimiter specified for the platform
dirname() Returns the directories of a path
extname() Returns the file extension of a path
format() Formats a path object into a path string
isAbsolute() Returns true if a path is an absolute path, otherwise false
join() Joins the specified paths into one
normalize() Normalizes the specified path
parse() Formats a path string into a path object
posix Returns an object containing POSIX specific properties and methods
relative() Returns the relative path from one specified path to another specified path
resolve() Resolves the specified paths into an absolute path
sep Returns the segment separator specified for the platform
win32 Returns an object containing Windows specific properties and methods

❮ 내장 모듈