Dennis
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
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
Ow yeah! This would be nice to have!
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
Dennis
Item author@Jurgen Indeed, this is fine and will probably also work with the installation with Ploi.
Dennis
Item authorVia the manage tab, you may now install NVM or N (up to you), we're still checking of we can expand functionality.
Tim Kleyersburg
@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
@Dennis just revisiting this. I've also didn't find nvm on the server anywhere. Is this correctly working?
Sander Jonk
I'm having the same issue. There seems to be no NVM after installing it through Ploi.
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
SMIT.
@Jurgen Without some weird quirky workarounds it actually is pretty difficult :(
DREIST Werbeagentur OG
looks like nvm gets installed in the home dir of the root user
/root/.nvm
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
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
René Sinnbeck
This seems to still not be working as expected.
@Dennis Should it perhaps be moved to In progress again?
kovinet
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
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
Please does anyone have a solution to this now ?
Jürgen
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 ...
Agopay HQ
Alright, thanks. I will check it out
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..
Jürgen
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.)
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.
Jürgen
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.
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 :)
Jürgen
Indeed, that's it.
Node version manager
-
Dennis moved item to board Live
1 year ago -
Dennis moved item to board In progress
1 year ago -
Dennis opened
2 years ago