Function fails with `ShopifyFunction is not defined` error

Deployed function for the first time to staging and now getting

Error:8:11 ShopifyFunction is not defined. Please rebuild your function using the latest version of Shopify CLI.
    at run_default (function.mjs:8:11)
    at run2 (function.mjs:98:10)
    at <anonymous> (eval_script:1:37)

Same code works well for the development app but fails for the staging app.

1 Like

Have you tried doing what the error message says?

Yes, @Luke.

Another line to make it 20 characters

I would check your dependencies are up to date, e.g. latest cli version and then retest on your dev app.

Also ensuring that the code is identical between dev and staging :slight_smile:

Are you still seeing this issue @Post_Purchase_Deals ?

Still no luck @Liam-Shopify. I have three .toml file for my app and my work flow is as below:

I am using the latest cli client:

@shopify/cli/3.82.0 darwin-x64 node-v20.18.1
  1. I develop using the shopify.app.toml file, created the function, built, deployed, works.
  2. I then switch to shopify.app.staging.toml file, deployed the app, didn’t work. After a few deploys, started working without any code changes.
  3. I then switch to shopify.app.live.toml file, deployed the app. The deployment process did build the function, deployed it, but then keeps giving me the same error.

I then removed the extension directory, generated a brand new extension, deployed it, same error.

I then manually shopify app function build, got javy confirmation that the function is built, deployed it and still getting the same exact error.

my-function-name        │ Bundling JS function...
my-function-name        │ Running javy...
my-function-name        │ Done!
Error:8:11 ShopifyFunction is not defined. Please rebuild your function using the latest version of Shopify CLI.
    at run_default (function.mjs:8:11)
    at run2 (function.mjs:28:10)
    at <anonymous> (eval_script:1:37)

I have the same issue, running shopify v3.80.7 and node v22.16.0.

IS there an update on this?

I’m getting the same issue.

Targeting 2025-07

I manually updated my extension dependencies to

"@shopify/shopify_function": "2.0.0"

reverting back to

"@shopify/shopify_function": "1.0.6"

resolves the error.

Hi @Post_Purchase_Deals

What version of the @shopify/shopify_function package are you using? Also if you run the function locally with shopify app function run - what happens?

2.0.0

Another line just to make it 20 chars

DMing for more details

It’s possible this is due to an older version of Javy being run with "@shopify/shopify_function": "2.0.0" - digging into this more.