Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

bash npm command not found

nmollet July 8, 2022

Hello everyone,

I am trying to setup a pipeline to deploy to production.

Using pipe: atlassian/ssh-run:0.4.1 I just want to execute an npm command on my production server.

The pipeline gives an error:

bash: npm: command not found

When connected as the same SFTP user on the production server terminal, npm -v successfully gives me the version: 6.9.0.

Having hard time understanding the difference between accessing SSH with a Bitbucket Pipeline and direct access to SSH.

I only setup 4 repository variables, called: SFTP_SERVER, SFTP_USER, SFTP_PASSWORD, and SFTP_PATH.

Help appreciated. Thanks.

The pipeline config file is:

image: php:7.4-fpm
definitions:
services:
mysql:
image: mysql:5.7
environment:
MYSQL_DATABASE: 'homestead'
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
MYSQL_USER: 'homestead'
MYSQL_PASSWORD: 'secret'
pipelines:
default:
- step:
name: Deploy to Production
deployment: production
script:
- pipe: atlassian/ssh-run:0.4.1
variables:
SSH_USER: $SFTP_USER
SERVER: $SFTP_SERVER
MODE: 'command'
DEBUG: 'true'
COMMAND: 'npm run updateprod'
PASSWORD: $SFTP_PASSWORD
LOCAL_PATH: $SFTP_PATH

Update: found some info saying that paths can be different when connected in SSH in "non interactive mode". Still trying to find how to handle the difference.

 

1 answer

0 votes
nmollet July 8, 2022

I found a solution that works for me:

source ~/.nvm/nvm.sh && source ~/.profile && npm run updateprod

Sourcing NVM and the profile before calling NPM.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events