path


1. Get Absolute Path

const path = require('path');

const absolutePath = path.resolve(__dirname, 'test.txt');
console.log(absolutePath); // /Users/username/Documents/test.txt

2. Get File Name

const path = require('path');

const fileName = path.basename('/Users/username/Documents/test.txt');
console.log(fileName); // test.txt

3. Get File Extension

const path = require('path');

const fileExtension = path.extname('/Users/username/Documents/test.txt');
console.log(fileExtension); // .txt

4. Get Directory Name

const path = require('path');

const directoryName = path.dirname('/Users/username/Documents/test.txt');
console.log(directoryName); // /Users/username/Documents

5. Join Paths

6. Resolve Relative Path

7. Normalize Path

8. Is Absolute Path

9. Is Relative Path

10. Get Root

11. Get Base

12. Get Dir

13. Get Ext

14. Get Name

15. Create Folder

16. Delete Folder

17. Create File

18. Read File

19. Append to File

20. Delete File

21. Copy File

22. Rename File

23. Check if File Exists

24. Get File Size

25. Get Last Modified Date

26. List Files in Directory

27. Iterate Over Files in Directory

28. Get Parent Directory

29. Get Current Working Directory

30. Change Current Working Directory

31. Get Unix File Permissions

32. Set Unix File Permissions

33. Get Process CWD

34. Get Home Directory

35. Get Temporary Directory

36. Get Path to Module