I've installed node/npm with NVM on Ubuntu 18.04. I can ssh into the server and run node -v
(v13.9.0) and npm -v
(v13.9.0), so they are installed and are executable by the user.
When I try and do this via the Laravel Envoy deploy tool I get the following error:
bash: line 5: npm: command not found
My Envoy script is super simple like so:
@servers(['main' => ['deploy@**.***.**.**']])
@task('deploy', ['on' => 'main'])
composer -V
npm -v
@endtask
So for some reason when Envoy logs into the server it doesn't have access to node/npm. Everything else installed on the system such as php and composer works fine.
Is there any reason that Envoy can't see the NVM node/npm install? Is Envoy not logging in with my deploy user?
When I check which npm it points to:
/home/deploy/.nvm/versions/node/v13.9.0/bin/npm
I've tried calling this directly in my ssh shell and get the correct result, npm runs as expected.
I then tried adding this to my Envoy script like so:
@task('deploy', ['on' => 'main'])
composer -V
/home/deploy/.nvm/versions/node/v13.9.0/bin/node -v
@endtask
However it returns the error:
‘node’: No such file or directory
Interestingly I can run node using Laravel Envoy by directly referencing the binary like so /home/deploy/.nvm/versions/node/v13.9.0/bin/node -v