Skip to content

Specify node-gyp as a dependency. #1378

Open
@quisido

Description

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.

Activity

mscdex

mscdex commented on Mar 16, 2024

@mscdex
Owner

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.

mscdex

mscdex commented on Mar 16, 2024

@mscdex
Owner

Besides, node-gyp is not required for this project anyway, it's optional.

quisido

quisido commented on Mar 16, 2024

@quisido
Author

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.

Relevant StackOverflow answer

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Specify `node-gyp` as a dependency. · Issue #1378 · mscdex/ssh2