node js __dirname code example
Example 1: __dirname javascript
console.log(__dirname) // "/Users/Sam/node-app/cronjobs"
console.log(process.cwd()) // "/Users/Sam/node-app"
Example 2: __dirname javascript
console.log(__dirname) // "/Users/Sam/node-app/src/api"
console.log(process.cwd()) // "/Users/Sam/node-app"
Example 3: __dirname javascript
node-app
├──index.js
├──public
├──src
│ ├──helpers.js
│ └──api
│ └──controller.js
├──cronjobs
│ ├──pictures
│ └──hello.js
└──package.json