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

Example o how to use https://pkg.go.dev/deps.dev/util/[email protected]/npm #184

Closed
pjebs opened this issue Feb 2, 2025 · 6 comments
Closed

Comments

@pjebs
Copy link

pjebs commented Feb 2, 2025

If I was to provide a package.json file with a list of dependencies, how can I use https://pkg.go.dev/deps.dev/util/[email protected]/npm to resolve all the dependencies to determine which versions of each npm package to download?

It seems to be undocumented how to use this package.

@cuixq
Copy link
Collaborator

cuixq commented Feb 2, 2025

@pjebs we do have an example on resolving npm dependencies. Feel free to let us know if there are more improvements to go!

@pjebs
Copy link
Author

pjebs commented Feb 3, 2025

@cuixq Why is it making a network call via a client?

@cuixq
Copy link
Collaborator

cuixq commented Feb 3, 2025

Network calls are needed to fetch metadata of npm packages and versions. The client being used is defined here.

@pjebs
Copy link
Author

pjebs commented Feb 3, 2025

@cuixq
So there is no way for me to provide the metadata myself and avoid the network call?
Will it work with current version of npm?

@sarnesjo-google
Copy link
Collaborator

Hi @pjebs! If you want, you can create your own implementation of the Client interface, which can provide metadata however you want. The LocalClient implementation (also in the file that @cuixq linked above) is an example of this, which is used for testing, but that could also be a good starting point for a custom implementation.

@pjebs pjebs closed this as completed Feb 3, 2025
@pjebs
Copy link
Author

pjebs commented Feb 3, 2025

Q1 Does this require a package.json or package.lock?

Q2 What does this package actually do? I have a package.json. If I provide it to this package, what does the package return back?

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

No branches or pull requests

3 participants