Dennis

Dennis

Live

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.

Saeed Rehman

Saeed Rehman

·
·

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.

no votes yet
Jürgen

Jürgen

·
·

Ow yeah! This would be nice to have!

no votes yet
Anees Khan

Anees Khan

·
·
no votes yet
Jürgen

Jürgen

·
·

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

no votes yet
Dennis

Dennis

Item author
·
·

@Jurgen Indeed, this is fine and will probably also work with the installation with Ploi.

no votes yet
Dennis

Dennis

Item author
· · Edited
·

Via the manage tab, you may now install NVM or N (up to you), we're still checking of we can expand functionality.

2 total votes
Jürgen
Tim Kleyersburg

Tim Kleyersburg

· · Edited
·

@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?

2 total votes
Cristian Balan Steets
Tim Kleyersburg

Tim Kleyersburg

·
·

@Dennis just revisiting this. I've also didn't find nvm on the server anywhere. Is this correctly working?

no votes yet
Sander Jonk

Sander Jonk

·
·

I'm having the same issue. There seems to be no NVM after installing it through Ploi.

no votes yet
Jürgen

Jürgen

·
·

@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

no votes yet
SMIT.

SMIT.

·
·

@Jurgen Without some weird quirky workarounds it actually is pretty difficult :(

no votes yet
DREIST Werbeagentur OG

DREIST Werbeagentur OG

·
·

looks like nvm gets installed in the home dir of the root user

/root/.nvm
no votes yet
Jürgen

Jürgen

·
·

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.

no votes yet
SMIT.

SMIT.

·
·

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
no votes yet
René Sinnbeck

René Sinnbeck

· · Edited
·

This seems to still not be working as expected.

@Dennis Should it perhaps be moved to In progress again?

4 total votes
Cristian Balan Stefan dev Tim Kleyersburg
kovinet

kovinet

· · Edited
·

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)

1 total vote
boundless
Cristian Balan

Cristian Balan

· · Edited
·

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.

no votes yet
Agopay HQ

Agopay HQ

·
·

Please does anyone have a solution to this now ?

no votes yet
Jürgen

Jürgen

· · Edited
·

Login via SSH as the user. Run

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm v0.39.7/install.sh | bash
source ~/.bashrc
nvm install ...
no votes yet
Agopay HQ

Agopay HQ

·
·

Alright, thanks. I will check it out

no votes yet
Tim Kleyersburg

Tim Kleyersburg

·
·

Did you get it to work in a deploy script? I always get nvm: command not found.

Tried sourcing the .bashrc file manually in the deploy process and a few other shenanigans, but no luck..

no votes yet
Jürgen

Jürgen

· · Edited
·

In my deploy script I use:

unset NPM_CONFIG_PREFIX && . ~/.nvm/nvm.sh && nvm use
npm install && npm run build

My project has a .nvmrc file with the version needed. (It's the version I've installed in the script above.)

1 total vote
Tim Kleyersburg
Tim Kleyersburg

Tim Kleyersburg

·
·

Thank you for your time and comment, unfortunately this does not work for me. Its not doing anything with nvm use and it still uses the wrong / default version.

no votes yet
Jürgen

Jürgen

· · Edited
·

Sadly it doesn't work for you. can't help you out any further since I can't look into your setup.

All I can advise is making sure you've logged into the server via (as the user your site is attached to). Install nvm for that user (so you end up with a folder /home/{user}/.nvm). After installing run source ~/.bashrc to load nvm, and run nvm install v... to install the required version.

1 total vote
Tim Kleyersburg
Tim Kleyersburg

Tim Kleyersburg

·
·

I forgot that nvm use doesn't automatically install but its the other way around. By calling nvm install instead of use its installing and also using the correct version and it's working now. Thank you very much :)

no votes yet
Jürgen

Jürgen

·
·

Indeed, that's it.

no votes yet
You may use @ to mention someone.

Node version manager

35 total votes
  • Dennis moved item to board Live

    1 year ago
  • Dennis moved item to board In progress

    1 year ago
  • Dennis opened

    2 years ago