Would it be possible to use the system's npm?
Is your feature request related to a problem? Please describe.
Shopify CLI bundles its dependencies, including @oclif/plugin-plugins, using esbuild.
For esbuild to work there needs to be an explicit import of all dependencies used, otherwise esbuild won't include it.
In this case, npm is installed as a dependency and then the code looks for the bin executable to run it. plugin-plugins explicitly tries to read the package.json file, which doesn't exist anymore once bundled. This makes it impossible for a bundled solution to work.
Describe the solution you'd like
Would it be possible to use the system npm to handle plugin installs? is there a reason to use a specific local version of npm?
Option 1: plugin-plugins could default to the system one if it can't find the local dependency.
Option 2: We could use an env-var to tell plugin-plugins to use the system npm.
What do you think?
Describe alternatives you've considered Couldn't think of any, do you think there are alternatives?
is there a reason to use a specific local version of npm?
Main reason is that we don't the plugin to break if the user has an older or newer version of npm that hasn't been tested yet.
Consider this scenario: plugin-plugins was tested against npm v10 but user has npm v5 installed globally. That would likely cause a number of issues for that user.
This was a bigger concern in the previous major versions where we used yarn instead of npm. Yarn, historically, has had more breaking changes than npm. But it's still something we want to safeguard against.
Option 1: plugin-plugins could default to the system one if it can't find the local dependency. Option 2: We could use an env-var to tell plugin-plugins to use the system npm.
What do you think?
Option 3: We publish @oclif/plugin-plugins-lite that doesn't ship npm (and yarn) as dependencies and instead uses globally installed versions.
Main benefit is that you get a substantially smaller plugin. Kinda of a selfish option because it's something that we'd likely use for the Salesforce CLI.
Would that work for you?
Option 3 would work perfectly for us!
Let me know if there is anything we can do to help with this :)
This issue has been linked to a new work item: W-15703207
@isaacroldan Got an update for you: we decided to hold on @oclif/plugin-plugins-lite since there's still a number of outstanding questions about how we'd consume in the Salesforce CLI.
However, #871 will still be merged. It's simply wrapping that findNpm logic in a try/catch and defaulting to the globally available version if it fails
That works perfectly for us, thanks for the update 🙏