Skip to content

deploy.sh script does not update environment node version #113

@phawxby

Description

@phawxby

Yarn is now available on Azure App Service and we've been making use of it via this update applied here.

  cd "$DEPLOYMENT_TARGET"

  if [ -e "$DEPLOYMENT_TARGET/yarn.lock" ]; then
    echo "Running yarn install --production"

    yarn config delete proxy
    yarn install --production --network-timeout 300000
    exitWithMessageOnError "yarn install failed"
  else
    echo "Running $NPM_CMD install --production"
    eval $NPM_CMD install --production
    exitWithMessageOnError "$NPM_CMD install failed"
  fi

Up until recently this has worked just fine. When we updated our application to require Node 12 the install process failed because selectNodeVersion doesn't actually update the system level node version. So when calling yarn it then called node internally and it was seeing the system version of Node 10, even though selectNodeVersion had selected Node 12, and it failed.

Inversely it seems the system version of Node got updated in the US West region sometime before 11/11/19, which meant our master branch still requiring Node 10 failed to deploy in one region because Yarn was running with Node 12 but the app required Node 10.

As a temporary solution I did this.

  if [ -e "$DEPLOYMENT_TARGET/yarn.lock" ]; then
    echo "Running yarn install --production"
    NODE_DIR="$(dirname $NODE_EXE)";
    export NODE=$NODE_EXE
    export PATH=$NODE_DIR:$PATH

    yarn config delete proxy
    yarn install --production --network-timeout 300000
    exitWithMessageOnError "yarn install failed"
  else
    echo "Running $NPM_CMD install --production"
    eval $NPM_CMD install --production
    exitWithMessageOnError "$NPM_CMD install failed"
  fi

This works and got the app deploying again, but it feels wrong. Surely selectNodeVersion should be updating the environment node version during the selection process so any future commands are automatically executed against the correct version. IE, shouldn't something like NVM be used?

Thanks.

Premier support ticket: 119110125000210

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions