相关文章推荐
率性的橙子  ·  Unity Animation -- ...·  3 月前    · 
被表白的小笼包  ·  jQuery ...·  1 年前    · 
完美的鸵鸟  ·  带您了解SQL ...·  1 年前    · 
文武双全的自行车  ·  selenium 笔记 --- ...·  2 年前    · 
独立的荔枝  ·  SQLServer时间相关 - ...·  2 年前    · 

Report this

What is the reason for this report?

Introduction to the Path Module in Node.js

Published on July 10, 2019
Cooper Makhijani

By Cooper Makhijani

Introduction to the Path Module in Node.js

Many people forget about one of Node’s most useful built-in modules, the path module. It’s a module with methods that help you deal with file and directory path names on the machine’s filesystem. In this article, we’re going to look at five of the tools path provides.

Before we can start using the path module, we have to require it:

const path = require('path');

Something of note: path works a little bit differently depending on your OS, but that’s beyond the scope of this article. To read more about the differences in the way path works on POSIX systems and Windows, see the path documentation.

Now that that’s out of the way, let’s look at all the things we can use path for.

path.join

path.join documentation

path.basename

path.basename documentation

path.dirname

path.dirname documentation

path.extname

path.extname documentation

path.normalize