Skip to content

Make JS package manager configurable (vs. detected) #324

Closed
@tkbrigham

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:

# Internal: Support all popular package managers.
def npm_install
return 'yarn add' if root.join('yarn.lock').exist?
return 'pnpm install' if root.join('pnpm-lock.yaml').exist?
'npm install'
end

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions