The ‘path’ module in Node.js is used to handle and transform file paths. Here are some examples of it in use:
```
const path = require(‘path’);
```
- path.normalize() This method is used to normalize the specified path:
\`\`\`javascript const path = require(‘path’); console.log(path.normalize(‘/content///test///example.html’)); // Outputs: ‘/content/test/example.html‘ \`\`\`
- path.basename() This method returns the last part of a path:
\`\`\`javascript const path = require(‘path’); console.log(path.basename(‘/content/test/example.html’)); // Outputs: ‘example.html‘ \`\`\`- path.extname() This method returns the extension of the path:
\`\`\`javascript const path = require(‘path’); console.log(path.extname(‘example.html’)); // Outputs: ‘.html‘ \`\`\`
- path.isAbsolute() This method determines if path is an absolute path:
\`\`\`javascript const path = require(‘path’); console.log(path.isAbsolute(‘/Users/yourusername/yourproject/example.html’)); // Outputs: true console.log(path.isAbsolute(‘example.html’)); // Outputs: false \`\`\`These are just some examples of what the ‘path’ module can do. You can refer to the Node.js documentation for more methods and usage.