Bash スクリプトのビルドスクリプト エラー。行 20: 予期しないトークン 'fi' 付近に構文エラーがあります

Bash スクリプトのビルドスクリプト エラー。行 20: 予期しないトークン 'fi' 付近に構文エラーがあります

私の bash スクリプトでエラーが発生します:

./buildscriptbuild.sh: line 20: syntax error near unexpected token 'fi'

以下の bash スクリプトをローカル システムでテストしました。この点についてどなたか助けていただけませんか。よろしくお願いします。

#!/bin/sh

cd /home/ec2-user/inoutserver
if git pull origin development; then
    if npm install; then
        if grunt build --force; then
            echo "build success"
        else
            if sudo cp -r dist/* /home/ec2-user/testfolder; then
                echo "deployment success!"
            fi
            else
            echo "deployment failed"
        fi
    else
        echo "build failed"
    fi
else
    echo "npm install failed"
fi

答え1

真ん中のこれを置き換えます:

        fi
        else
        echo "deployment failed"

による :

        else
           echo "deployment failed"
        fi

関連情報