- SSH to forge server and run this command
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
- In forge site deployment script. add this script to install and change the version
echo 'configuring nvm...';
. ~/.nvm/nvm.sh
nvm install v20.0.0
nvm use v20.0.0
echo 'Running > npm install';
npm install
echo 'Running > npm run build';
npm run build
Top comments (3)
Why would you want nvm on you server?
Nvm is a development tool which allows you to use different node version in diffferent projects or branches.
If you want a new node version on you server. Just update it as you would php.
What about running multiple applications on one instance?
If it is really needed to have multiple node versions. I would install the versions that are needed, and use the full path to start the server.
I would only do this as a temporary fix, and update the code to the newest version as soon as possible.
I want servers to only have the essential tools. I even remove npm from the server, do the build process in the CI flow and move the build code to the server.