When yarn generate the cmd file for a executable defined in the bin section of the package.json, the path to the executable is set incorrectly as the scope folder is not in the path.
Error: Cannot find module 'C:\\node_modules\packageB\src\utility.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The path of the bin should be 'C:\\node_modules\@scope\packageB\src\utility.js', not 'C:\\node_modules\packageB\src\utility.js' .
If the current behavior is a bug, please provide the steps to reproduce.
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
When yarn generate the cmd file for a executable defined in the bin section of the package.json, the path to the executable is set incorrectly as the scope folder is not in the path.
The path of the bin should be 'C:\\node_modules\@scope\packageB\src\utility.js', not 'C:\\node_modules\packageB\src\utility.js' .
If the current behavior is a bug, please provide the steps to reproduce.
All the steps described bellow are already available by cloning the following repository: https://github.com/francoisgergaud/debug-yarn-workspaces-bin/tree/main
Please mention your node.js, yarn and operating system version.
Yarn 1.22.19, Node 16.18, Windows 10 x64 (we are stuck with yarn classic on our project).
Other:
It works when packageB is not scoped (the scope prefix is removed from the package's name, see https://github.com/francoisgergaud/debug-yarn-workspaces-bin/tree/without-scope). It also works on Linux with the scope prefix in the package's name.