ssh2
ssh2 copied to clipboard
Specify `node-gyp` as a dependency.
I'm getting this error in my Cloudflare Worker when using Yarn 4:
➤ YN0000: │ ssh2@npm:1.15.0 STDOUT Usage Error: Couldn't find a script name "node-gyp" in the top-level (used by ssh2@npm:1.15.0). This typically happens because some package depends on "node-gyp" to build itself, but didn't list it in their dependencies. To fix that, please run "yarn add node-gyp" into your top-level workspace. You also can open an issue on the repository of the specified package to suggest them to use an optional peer dependency.
While I can go about manually installing it at the root, I figured it was worth asking to fix it at the source if possible.
My projects target npm because that's what's always been bundled with node. npm bundles node-gyp. AFAIK there is no way to ensure that only one copy of it is installed if I were to add it as an explicit dependency in one way or another.
Besides, node-gyp is not required for this project anyway, it's optional.
I'm guessing the concern is that it should be marked as an optional peer dependency, per the last sentence in the error:
You also can open an issue on the repository of the specified package to suggest them to use an optional peer dependency.
It should have a peerDependency entry because you expect the consuming environment to provide it for you, and it should have a peerDependenciesMeta entry because -- as you said -- it's optional.
As is, the failure is fatal, because it is neither marked as provided by the environment nor optional.
It seems like a trivial fix. I can open a PR.