Score:0

yarn: not found in deployer

bd flag

I installed the yarn by nvm in Ubuntu20.04.

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 Ubuntu20.04 to make yarn works in deployer task?

Thanks a lot!

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.