How bin linking works in node.js npm and yarn and monorepos

yarn pnpm run thing npm run thing are types of run commands we run all the time when working in node.js. But, how does that actually all work? What about monorepos?