4

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

twigg
  • 3,753
  • 13
  • 54
  • 96
  • I'm having the same issue with getting Envoyer to use nvm, despite having installed nvm directly on the VPS as the user `forge` (the Envoyer user as well). Did you ever figure this out? – Elly Post Apr 20 '20 at 16:49

1 Answers1

3

I had similar problem where running nvm use I got same error command not found. Seems like nvm is not activated from the profile files (e.g. ~/.bashrc). I looked at the nvm README and just copied source lines to my Envoy script.

@task('deploy')
    export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
    nvm use # Now works!
@endtask
ncla
  • 803
  • 9
  • 22