Get baseurl on nodejs
In Node.js, you can get the base URL of your project using the __dirname global variable, which holds the absolute path of the directory that contains the currently executing JavaScript file.
Here's an example code snippet that demonstrates how to get the base URL of your Node.js project:
const path = require('path'); const baseDir = path.resolve(__dirname); console.log('Base URL:', baseDir);
This code will output the base URL of your project, which is the absolute path to the directory that contains your main JavaScript file. You can use this base URL to reference other files in your project.
Komentar
Posting Komentar