Based on this environment setup code
https://github.com/frappe/bench/blob/develop/bench/utils.py#L604
My guess is to focus on how this applies in your particular case apps/your_custom_app/package.json
These two apps/frappe/package.json and apps/erpnext/package.son will give you clues too.
Perhaps this tutorial example will help Creating a Package | Yarn
edit: This could be a clue or tip How to import a .js module in Frappe?
and also this How to add a node module to a custom app?