Can't build product discount function: 'Could not resolve @shopify/shopify_function/run'

Can't build product discount function: 'Could not resolve @shopify/shopify_function/run'

jordanaf808
Shopify Partner
4 0 1
I tried to run Shopify's Functions Discount tutorial, going through the steps listed here: Scaffold An App  and here: Build A Discounts Function, but it crashes while loading the preview link. I'm able to init the new app, generate a new product discount function extension, run the app, log-in to my account, and return back a preview link, but then it crashes right away with this error:

10:01:15 │ graphiql         │ GraphiQL server started on port 3457
10:01:16 │ product-discount │ Building function product-discount...
10:01:16 │ product-discount │ Building GraphQL types...
10:01:17 │product-discoun │ (node:16525) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative
                         instead.
10:01:17 │ product-discount │ (Use `node --trace-deprecation ...` to show where the warning was created)
10:01:17 │ product-discount │ Bundling JS function...
╭─ error ───────────────────────────────────────────────────────────────────────╮
│                                                                               │
│  Build failed with 1 error:                                                   │
│  <stdin>:2:26: ERROR: Could not resolve "@shopify/shopify_function/run"       │
│                                                                               │
│  To investigate the issue, examine this stack trace:                          │
│    at <stdin>:2:26: ERROR: Could not resolve "                                │
│    at failureErrorWithLog (../../../.nvm/versions/node/v21.7.3/lib/node_modu  │
│    les/@shopify/cli/node_modules/esbuild/lib/main.js:1650)                    │
│    at (../../../.nvm/versions/node/v21.7.3/lib/node_modules/@shopify/cli/nod  │
│    e_modules/esbuild/lib/main.js:1058)                                        │
│    at (../../../.nvm/versions/node/v21.7.3/lib/node_modules/@shopify/cli/nod  │
│    e_modules/esbuild/lib/main.js:1003)                                        │
│    at buildResponseToResult (../../../.nvm/versions/node/v21.7.3/lib/node_mo  │
│    dules/@shopify/cli/node_modules/esbuild/lib/main.js:1056)                  │
│    at (../../../.nvm/versions/node/v21.7.3/lib/node_modules/@shopify/cli/nod  │
│    e_modules/esbuild/lib/main.js:1085)                                        │
│    at <computed> (../../../.nvm/versions/node/v21.7.3/lib/node_modules/@shop  │
│    ify/cli/node_modules/esbuild/lib/main.js:703)                              │
│    at handleIncomingPacket (../../../.nvm/versions/node/v21.7.3/lib/node_mod  │
│    ules/@shopify/cli/node_modules/esbuild/lib/main.js:763)                    │
│    at readFromStdout (../../../.nvm/versions/node/v21.7.3/lib/node_modules/@  │
│    shopify/cli/node_modules/esbuild/lib/main.js:679)                          │
│    at emit (node:events:519)                                                  │
│    at emit (node:domain:488)                                                  │
│                                                                               │
╰───────────────────────────────────────────────────────────────────────────────╯
For the verbose error output and more information, see the GitHub issue I created for this.

When building this app I initially had ESBUILD errors about using x64 on arm64, because I recently migrated from an Intel Mac to M2. So, I uninstalled old shopify-cli, ruby, and homebrew. I then installed new arm64 Homebrew version, the latest ruby, then the latest shopify-cli with npm -g instead of brew. Node was also installed under Intel architecture, so I removed it and the node_modules folder, then reinstalled it while in arm64 arch. Now I get the error above.

I also tried using Yarn instead of NPM, I tried with terminal running under Rosetta 2, I tried Intel and Arm64 arch, nothing worked.

Please help me figure this out so I can stay up to date with Shopify changes, Thanks!

Operating System: 2023 M2 MacOS Sonoma 14.5

Shopify CLI version: 3.51.0 and 3.61.0

Shell: zsh

Node version: v20.14.0 and v21.7.3

Ruby 3.1 and 3.3.2

Replies 0 (0)