This will give path to the project's local bin
npm install project-bin-path> Find path to local bin of Node.js or NPM package
Inspired by sindresorhus/pkg-dir
npm install project-bin-path
or
yarn add project-bin-path
Project structure
``text`
š Users/
š ajaynarainmathur/
š test-project/
š node_modules/
š .bin/
š package.json
š dist/
š foo.js
`javascript
// foo.js
const projectBinPath = require('project-bin-path')
projectBinPath(__dirname).then(binPath => {
console.log(binPath);
// /Users/ajaynarainmathur/test-project/node_modules/.bin`
});
projectBinPath([cwd])
ā® Returns a promise of path to .bin folder of the project or null if project is not found
projectBinPath.sync([cwd])
ā® Returns the path to .bin of the project or null.
#### cwd
ā® Directory to start from.
Type: stringprocess.cwd()
Default:
1. When you need to get path to excutables in package ( not the project but of your local package ) just do projectBinPath(__dirname) => [...]/project/node_modules/your_package/node_modules/.bin
2. When you need to get path to excutables in project ( project using you package* ) just do projectBinPath() => [...]/project/node_modules/.bin`
MIT š» Ajay Narain Mathur