I installed the yarn by nvm.
root@server:~# which yarn
/root/.nvm/versions/node/v19.0.0/bin/yarn
It works when I login the machine and use yarn
in terminal.
root@server:~# yarn -v
1.22.19
But once I try to run yarn
in deployer
task,
task('deploy:yarn', function () {
run('cd {{release_path}} && yarn install', ['timeout' => 600]);
});
The command "cd /var/www/my-web-project/releases/1 && yarn install" failed.
Exit Code: 127 (Command not found)
Host Name: example.com
bash: line 1: yarn: command not found
It will throw out error: yarn: command not found
I try to run the yarn
in a shell bash via a deployer
task
task('deploy:upload-front-end-shell', function () {
upload('build-front-end.sh', '{{release_path}}/build-front-end.sh');
});
build-front-end.sh
#!/bin/bash
yarn && yarn build
or
alias yarn=$(which yarn)
yarn && yarn build
or
yarn_path=$(which yarn)
$yarn_path && $yarn_path build
None of those shell works via deployer
task, but works when I login the machine and run the shell manually.
How can I config my ubuntu20.04 to make yarn
works in deployer
task?