# Node version manager

**Project:** Servers | **Board:** Live | **Votes:** 35
**URL:** https://roadmap.ploi.io/projects/1-server-level-requests/items/7-node-version-manager

---

Currently Ploi installs node/npm LTS version.
We have some projects that need an older version of node/npm to build assets, so it would be very helpful for us to have a node version manager installed by Ploi so that we can switch node version in the deploy script.
For example `nvm` or `n`.

They both have the option to set a dot file in your repo and it will set the correct node version from that file.
github.com/nvm-sh/nvm/blob/master/README.md#nvmrc
github.com/tj/n#specifying-node-versions
Once a user added the file to their project they will only need to add `nvm use` or `n auto` to their project.

---

## Comments

**Saeed Rehman** (2022-08-04T13:53:39+00:00):
Very much needed. To be Honest I have a legacy project that is vey critical and running on Node 10.2. We started it in 2018 on LaravelForge. One of the reasons for not migrating it to Ploi yet is that I am too lazy to install Old node version manually.

**Jürgen** (2022-10-05T19:33:40+00:00):
Ow yeah! This would be nice to have!

**Anees Khan** (2022-11-09T20:35:09+00:00):
[@Dennis](/user/Dennis) 

**Jürgen** (2023-02-10T10:16:42+00:00):
FYI, for now I install nvm on behalf of the user of the website and in the deploy script I put: `. ~/.nvm/nvm.sh && nvm use 16`

**Dennis** (2023-02-10T10:19:01+00:00):
[@Jurgen](/user/Jurgen) Indeed, this is fine and will probably also work with the installation with Ploi.

**Dennis** (2023-03-30T11:32:26+00:00):
Via the manage tab, you may now install NVM or N (up to you), we're still checking of we can expand functionality.

**Tim Kleyersburg** (2023-05-15T10:04:52+00:00):
[@Dennis](/user/Dennis) I've tried using this feature today by first installing nvm on the server over the manage tab and then just using the command `nvm use auto` in my deploy script. This outputs `ploi.sh: line 8: nvm: command not found`

Can you tell me/us how to correctly use this feature?

**Tim Kleyersburg** (2023-06-09T09:36:14+00:00):
[@Dennis](/user/Dennis) just revisiting this. I've also didn't find nvm on the server anywhere. Is this correctly working?

**Sander Jonk** (2023-07-31T10:24:31+00:00):
I'm having the same issue. There seems to be no NVM after installing it through Ploi.

**Jürgen** (2023-07-31T11:14:28+00:00):
[@Dennis](/user/Dennis) could you please take a look? It's sad to see this issue still open. Shouldn't be that difficult to make NVM available to all system users one would think. Thanks in advance

**SMIT.net** (2023-07-31T11:17:21+00:00):
[@Jurgen](/user/Jurgen) Without some weird quirky workarounds it actually is pretty difficult :( 

**DREIST Werbeagentur OG** (2023-07-31T13:35:54+00:00):
looks like nvm gets installed in the home dir of the root user
```bash
/root/.nvm
```

**Jürgen** (2023-07-31T15:26:03+00:00):
For the time being you can install it per system user.
```
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
```
See https://github.com/nvm-sh/nvm.

**SMIT.net** (2023-07-31T19:58:05+00:00):
There are multiple issues to solve here, for example:
- using nvm on other users then Ploi
- pm2 is still run on "system node"
- What about globally installed npm packages.

I think i have a dirty workaround for the first issue that requires some, keep in mind this is not production ready, use at your own risk.

### Install nvm via the ploi user

```
mkdir /usr/local/nvm
curl https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | NVM_DIR=/usr/local/nvm bash
```

### The dirty path 
that should be changed with group privileges for example but did not get this to work yet. This makes it so every user can install and use nvm cache.

```
mkdir /usr/local/nvm/.cache && chmod -R 777 /usr/local/nvm/.cache
mkdir /usr/local/nvm/versions && chmod -R 777 /usr/local/nvm/versions
mkdir /usr/local/nvm/alias && chmod -R 777 /usr/local/nvm/alias
```

### Add nvm init to profiles

```
echo 'export NVM_DIR="/usr/local/nvm"' | sudo tee -a /etc/profile.d/nvm.sh
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | sudo tee -a /etc/profile.d/nvm.sh
```

**René Sinnbeck** (2023-11-28T11:07:53+00:00):
This seems to still not be working as expected. 

[@Dennis](/user/Dennis) Should it perhaps be moved to In progress again?

**kovinet** (2024-01-12T12:46:28+00:00):
So I installed NVM via Ploi but even the default ploi user doens't have access to ploi in terminal, I get `Command 'nvm' not found` error (Ubuntu 22 on Hetzner)

**Cristian Balan** (2024-05-01T10:45:28+00:00):
According to https://stackoverflow.com/questions/11542846/nvm-node-js-recommended-install-for-all-users#comment58129097_19040346

> ... you should NOT EVER install `nvm` as root. `nvm` is per-user. If you want to share node across users, nvm is the wrong tool to use.

**Agopay HQ** (2024-07-19T12:30:50+00:00):
Please does anyone have a solution to this now ?

**Reind Dooyeweerd** (2025-10-27T11:24:28+00:00):
Found out today this still is an issue, any chance this will be resolved in the near future?

