Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify node-gyp as a dependency. #1378

Open
quisido opened this issue Mar 16, 2024 · 3 comments
Open

Specify node-gyp as a dependency. #1378

quisido opened this issue Mar 16, 2024 · 3 comments

Comments

@quisido
Copy link

quisido commented Mar 16, 2024

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.

@mscdex
Copy link
Owner

mscdex commented Mar 16, 2024

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
Copy link
Owner

mscdex commented Mar 16, 2024

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

@quisido
Copy link
Author

quisido commented Mar 16, 2024

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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants