Hi!
I know this is not a Yarn issue but I really don't know where else to look for help.
I'm trying to automatize a deployment process that requires running a npm script on the remote server.
What I've tried so far is to use a very simple make script to rsync my changes and ssh run the npm script using yarn (i.e. ssh user@remote:/path 'cd var/www/path; yarn run build'). Problem is, the PATH isn't loaded when trying to run a command via SSH without properly loading the interactive shell. So yarn run build throws a 'Yarn requires Node 4.7.0 or higher' error.
I tried sourcing the .bashrc and .bash_profile before running the command, tried using the -t flag with SSH too. Neither worked.
Is there a way to actually accomplish this? Does a workaround exists? I can't really think of other way to automatize running the 'yarn run build' command.
Hello there.
Had the same issue when i was implementing continuous integration.
You are right about the PATH not being loaded, so it couldn't load Node. The solution is to export PATH in the command itself.
Do this on your remote machine
My Result:
_/home/admin/.nvm/versions/node/v8.9.4/bin/node_
export PATH=/home/admin/.nvm/versions/node/v8.9.4/bin;
My Result:
_yarn: /usr/bin/yarn /usr/share/yarn_
export PATH=/home/admin/.nvm/versions/node/v8.9.4/bin:/usr/bin;
Do a 'whereis' on every missing module and export their PATHs too.
'whereis sed' 'whereis readlink' 'whereis uname'
My Result:
_sed: /bin/sed /usr/share/man/man1/sed.1.gz /usr/share/info/sed.info.gz
readlink: /bin/readlink /usr/share/man/man2/readlink.2.gz /usr/share/man/man1/readlink.1.gz
uname: /bin/uname /usr/share/man/man2/uname.2.gz /usr/share/man/man1/uname.1.gz_
export PATH=/home/admin/.nvm/versions/node/v8.9.4/bin:/usr/bin:/bin;
TL;DR
Export PATH of required modules in the command itself.
ssh user@remote:/path 'cd var/www/path; export PATH=
@ramprasad5394 hey, thanks a lot for the detailed explanation! I'll look into and let you know how it worked for me.
Most helpful comment
Hello there.
Had the same issue when i was implementing continuous integration.
You are right about the PATH not being loaded, so it couldn't load Node. The solution is to export PATH in the command itself.
Do this on your remote machine
Do a 'whereis node' to find your node installation.
export the resulting folder you get before running yarn
My Result:
_/home/admin/.nvm/versions/node/v8.9.4/bin/node_
export PATH=/home/admin/.nvm/versions/node/v8.9.4/bin;
Yarn would probably be not found now and will throw an error 'bash: yarn: command not found'
Do a 'whereis yarn' to find your yarn installation.
export the resulting folder you get before running yarn
My Result:
_yarn: /usr/bin/yarn /usr/share/yarn_
export PATH=/home/admin/.nvm/versions/node/v8.9.4/bin:/usr/bin;
Other dependencies that are required by Yarn wont be found now.
I got something like this.
_/usr/bin/yarn: 2: /usr/bin/yarn: sed: not found
/usr/bin/yarn: 3: /usr/bin/yarn: readlink: not found
/usr/bin/yarn: 5: /usr/bin/yarn: uname: not found_
Do a 'whereis' on every missing module and export their PATHs too.
'whereis sed' 'whereis readlink' 'whereis uname'
My Result:
_sed: /bin/sed /usr/share/man/man1/sed.1.gz /usr/share/info/sed.info.gz
readlink: /bin/readlink /usr/share/man/man2/readlink.2.gz /usr/share/man/man1/readlink.1.gz
uname: /bin/uname /usr/share/man/man2/uname.2.gz /usr/share/man/man1/uname.1.gz_
export PATH=/home/admin/.nvm/versions/node/v8.9.4/bin:/usr/bin:/bin;
TL;DR:/usr/bin:/bin; yarn run build')
Export PATH of required modules in the command itself.
ssh user@remote:/path 'cd var/www/path; export PATH=