Categories
JavaScript Answers

How to go back 1 folder level with __dirname with JavaScript?

Spread the love

Sometimes, we want to go back 1 folder level with __dirname with JavaScript.

In this article, we’ll look at how to go back 1 folder level with __dirname with JavaScript.

How to go back 1 folder level with __dirname with JavaScript?

To go back 1 folder level with __dirname with JavaScript, we can use the '../ string.

For instance, we write

const path = require("path");
const p = path.join(__dirname, "../");

to call path.join with __dirname and "../" to return a string with the path one level up from __dirname.

Conclusion

To go back 1 folder level with __dirname with JavaScript, we can use the '../ string.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.