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

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

Open
tkbrigham opened this issue Dec 22, 2022 · 3 comments
Open

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

tkbrigham opened this issue Dec 22, 2022 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@tkbrigham
Copy link

tkbrigham commented Dec 22, 2022

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

@ElMassimo ElMassimo added the enhancement New feature or request label Dec 24, 2022
@ElMassimo
Copy link
Owner

ElMassimo commented Dec 24, 2022

Hi Thomas!

The detection logic could be improved by using pkg-up to detect the project root before checking the lockfiles.

Passing the preferred package manager to install with a --with flag would also be a nice improvement:

bundle exec vite install --with pnpm

I'd prefer this second option, as it's a small change, and avoids introducing a dependency to the install process.

@ElMassimo ElMassimo added the help wanted Extra attention is needed label Mar 16, 2023
@negreirosleo
Copy link

@ElMassimo May I implement this?

@ElMassimo
Copy link
Owner

Hi Leonardo!

Passing the preferred package manager to install with a --with flag

I think that would be a simple way to make the installer more flexible, without adding another dependency or increasing the complexity.

Go for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants