diff --git a/deploy.php b/deploy.php index 09afceac6..440a0fa0b 100644 --- a/deploy.php +++ b/deploy.php @@ -27,9 +27,17 @@ // The Laravel recipe doesn't build any frontend assets, so we'll // need to do it ourselves here + +// NVM doesn't play well with deployer +// https://github.com/deployphp/deployer/issues/2535 +// +// Must call use_nvm in every run command related to npm so that +// it's sourced in the current run's shell +set('use_nvm', 'source $HOME/.nvm/nvm.sh'); + task('deploy:frontend', function () { - run('npm install'); - run('npm run build'); + run('{{use_nvm}} && cd {{release_path}} && npm ci'); + run('{{use_nvm}} && cd {{release_path}} && npm run build'); })->desc('Build frontend assets'); after('deploy:vendors', 'deploy:frontend');