The ShopifyBuy object is exported from the js library you have imported.
You can move the script in index.html and try accessing the Shopify button module.
Here is shopify's official doc: https://www.shopify.com/in/partners/blog/introducing-buybutton-js-shopifys-new-javascript-library
If you are able to create a stackblitz project I might be able to help you more.
PS: New to Stackoverflow, Apologies in advance.