Load package.json from current work directory.
$ npm install --save current-pkg
const currentPkg = require('current-pkg')
currentPkg()
/*
{
pkg: {name: 'packageName', version...}
}
*/
currentPkg(path.join(__dirname, '../another-package'))
/*
{
pkg: {name: 'otherPackageName', version...}
}
*/
// not found
currentPkg()
/*
{
error: new Error('Cannot find module ...')
}
*/
MIT © EGOIST