get project root folder to find the root folder inside the project we just need to look for the package.json file
const { existsSync } = require('node:fs')
const { join } = require('node:path')
const getAppRootDir = () => {
const currentDir = __dirname
let appRootDir = currentDir
while (!existsSync(join(appRootDir, 'package.json'))) {
appRootDir = join(appRootDir, '..')
}
return appRootDir
}
module.exports = { getAppRootDir }