Languages
[Edit]
EN

TypeScript / Node.js - resolve path

3 points
Created by:
Mahir-Bright
1281

In this article, we would like to show you how to resolve path in Node.js.

Quick solution:

Note:

The resolve() method will return the absolute path according to the current working directory and operating system (Windows, Linux, etc.).

 

Practical example

Edit

In this example, we use path.resolve() method that resolves the specified paths into an absolute path.

Let's suppose we have the following directory structure:

index.js file contains:

Go to C:\Project\ and run index.js file using:

Output:

 

See also

Edit
  1. TypeScript / Node.js - install Node types (type declarations)

  2. Node.js - resolve path

References

Edit
  1. Path | Node.js v16.9.0 Documentation

Alternative titles

  1. TypeScript / Node.js - safe way to add path to path (resolve path)
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join