What is @pnpm/link-bins?
@pnpm/link-bins is a utility package that helps in linking binaries from node_modules/.bin to a specified directory. This is particularly useful in monorepos or when working with multiple packages that need to share executables.
What are @pnpm/link-bins's main functionalities?
Linking Binaries
This feature allows you to link all binaries from the node_modules/.bin directory to a specified destination directory. This is useful for making executables available in a consistent location.
const { linkBins } = require('@pnpm/link-bins');
const path = require('path');
const sourceDir = path.join(__dirname, 'node_modules/.bin');
const destDir = path.join(__dirname, 'bin');
linkBins(sourceDir, destDir).then(() => {
console.log('Binaries linked successfully');
}).catch(err => {
console.error('Error linking binaries:', err);
});
Other packages similar to @pnpm/link-bins
symlink-dir
symlink-dir is a package that creates symbolic links for directories. While it can be used to link binaries, it is more general-purpose and not specifically designed for linking node_modules/.bin executables.
npm-link
npm-link is a built-in npm command that allows you to symlink a package folder. It is useful for local development but does not specifically focus on linking binaries from node_modules/.bin.
@pnpm/link-bins
Link bins to node_modules/.bin
Installation
<pnpm|yarn|npm> add @pnpm/link-bins
Usage
import linkBins, {linkBinsOfPackages} from '@pnpm/link-bins'
function warn (msg) { console.warn(msg) }
await linkBins('node_modules', 'node_modules/.bin', {warn})
const packages = [{manifest: packageJson, location: pathToPackage}]
await linkBinsOfPackages(packages, 'node_modules/.bin', {warn})
License
MIT