mason-org / mason-org/mason.nvim

Configurable `npm` command

Open
#166 10 comments 9 reactions 0 assignees View on GitHub
enhancement
Dominant language
Lua
Stars
10.5k
Forks
338
PR merge metrics
No merged PRs in 30d

Description

### Is your feature request related to a problem? Please describe.

I am often working across a number of repositories that are on different versions of Node, including major versions. Typically `npm` modules are installed for the current version of node, but for almost all of the packages that are being used by neovim I am going to want to use a separate node version e.g. I am having to work on a repo using node v12 but for various language servers and formatters I want to use v16 as some of them don't even support v12. There are a number of ways of achieving this but I have found that [volta.sh](https://volta.sh/) does this very nicely, the main caveat being that instead of doing a normal install:
```
npm install package_name -g
```
to get the separate version you use:
```
volta run --node 16 npm install package_name -g
```
[see here](https://docs.volta.sh/advanced/packages#volta-090-and-beyond)
That being said, from what I can tell from `lua/mason-core/managers/npm/init.lua` it doesn't look as if global modules are being used.

### Describe the solution you'd like

I think I saw that for your nvim-lsp-installer you said that you weren't going to support yarn, I don't know if that still applies here? but one possible solution could be to allow users to configure the command used for `npm` installations. Being able to fix/lock the node version of the "package" where Mason installs npm dependencies.

Strictly speaking, the solution, rather than implementation, that I am interested in is being able to have the `npm` managed dependencies used in my neovim config to be independent of my node version.

### Describe potential alternatives you've considered

Not using Mason to manage `npm` dependencies.
Living with some tools not working when working on repos with old node versions.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with lua/mason-core/managers/npm/init.lua to understand how npm-managed dependencies are installed. Determine how a configurable npm command could let users select an independent Node version, then verify that the configured command is used for npm installations without breaking the existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, node.js
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.