1

I'm trying to deploy a Laravel app to a Jelastic Cloud. My problem is, I don't know how to build my scripts with npm. Until now I use laravel forge & envoyer and build the scripts with npm run prod on the server while deploying.

But How to do that in Jelastic Cloud? Do I need to add a node.js server just for the deployment process? Or is it possible to install node on the nginx server in Jelastic cloud?

(I know I could build the scripts locally before uploading, but that makes it dependant on my dev machine, which I don't like)

ndberg
  • 3,391
  • 1
  • 21
  • 36

2 Answers2

1

We (Layershift) provide an add-on that installs node.js on a Jelastic PHP node for this exact reason.

Speak to your Jelastic provider, or move to one that offers this.

Damien - Layershift
  • 1,508
  • 8
  • 15
1

You can install a pre-compiled NodeJS from https://nodejs.org/en/download/, extract it to a home directory in Jelastic, and then add the new path to the PATH var accordingly. Here is a detailed flow.

Enter your php container through WebSSH or SSH and run the following commands

curl -sk https://nodejs.org/dist/v16.14.2/node-v16.14.2-linux-x64.tar.xz | tar -xJC $HOME --strip-component=1
rm -f $HOME/{CHANGELOG.md,LICENSE,README.md}
chmod +x $HOME/bin/*
echo "export PATH=$PATH:$HOME/bin:" >> $HOME/.bash_profile
. $HOME/.bash_profile

(Here NodeJS LTS version is used, you can replace v16.14.2 with any other preferred version).

Then you can check if it's installed by issuing

node -v
npm -v

Also instead of editing .bash_profile to add path to NodeJS, you can add $HOME/bin path via the dashboard to the PATH variable as described here

Virtuozzo
  • 1,993
  • 1
  • 10
  • 13
  • 1
    Thanks this works. Unfortunately it's CentOS 7 under the hood, as of this I cannot use node18. – ndberg Feb 07 '23 at 08:37