Make JS package manager configurable (vs. detected) #324
Description
Is your feature request related to a problem? Please describe.
When I run bundle exec vite install
in my pnpm subproject (which is a Rails app), I get the following:
Installing js dependencies
npm ERR! code ENOTSUP
npm ERR! notsup Unsupported engine for rollup@3.7.5: wanted: {"node":">=14.18.0","npm":">=8.0.0"} (current: {"node":"14.20.0","npm":"6.14.11"})
npm ERR! notsup Not compatible with your version of node/npm: rollup@3.7.5
npm ERR! notsup Not compatible with your version of node/npm: rollup@3.7.5
npm ERR! notsup Required: {"node":">=14.18.0","npm":">=8.0.0"}
npm ERR! notsup Actual: **{"npm":"6.14.11","node":"14.20.0"}
It is looking at npm versions, even though my pnpm is updated. I believe this is because the subproject (which I believe is the config.root) does not detect a pnpm-lock.yaml file (source). pnpm-lock.yaml does exist one directory above my subproject, in my repo (and pnpm workspace) root.
Describe the solution you'd like
It would be easier to allow a user to pass in their preferred package manager as a CLI argument (or ENV var) when running bundle exec vite install
versus relying on detection. The detection is great as a default, but should be configurable/overridable by the user.
Describe alternatives you've considered
None, but happy to do so if it would help. When I hardcode my preferred pnpm install
into the function below, bundle exec vite install
works as expected. I'm happy to submit the PR if this suggestion seems reasonable!
Additional context
Context linked above, but the def npm_install
method is probably the main place I would look to make changes, along with some command line argument parsing. Relevant function:
vite_ruby/vite_ruby/lib/vite_ruby/cli/install.rb
Lines 118 to 124 in eb8f678