Sometimes, we want to get the full file path in Node.js.
In this article, we’ll look at how to get the full file path in Node.js.
How to get the full file path in Node.js?
To get the full file path in Node.js, we can use the path.resolve
method.
For instance, we write
const path = require("path");
const absolutePath = path.resolve("/foo/bar/baz");
to call path.resolve
with the relative path string to return the absolute path equivalent of the relative path.
Conclusion
To get the full file path in Node.js, we can use the path.resolve
method.