Getting error on "shopify app dev"

Topic summary

Custom Shopify app runs locally and loads, but opening the browser preview triggers build errors and the in‑app “Generate a product” button does not work.

Error details point to Vite/esbuild pre-bundling: “Failed to resolve entry for package ‘crypto’ [plugin vite:dep-pre-bundle]”, with the build expecting var crypto = require('crypto');. Multiple screenshots show the error traces. “crypto” refers to the Node.js core crypto module.

Environment reported:

  • Node v22.3.0, npm 10.8.1
  • Shopify CLI 3.61.2
  • Tried Yarn as an alternative; issue persists.

No fix or workaround is provided in the thread. A follow-up asks whether a solution for the crypto error was found, indicating the issue remains unresolved and open.

Summarized with AI on December 17. AI used: gpt-5.

I created a custom app and then try to run the local env after app installation, the app loads but when I open the preview in the browser then I get some error logs and the “Generate a product” button does not work


.

I checked the logs and it is showing following errors:

  • ✘ [ERROR] Failed to resolve entry for package “crypto”. The package may have incorrect main/module/exports specified in its
    package.json. [plugin vite:dep-pre-bundle]
    21:04:42 │ remix │
    21:04:42 │ remix │ node_modules/vite/node_modules/esbuild/lib/main.js:1225:21:
    21:04:42 │ remix │ 1225 │ let result = await callback({
  • Ultimately the build is expecting var crypto = require(‘crypto’);

Node version: v22.3.0

Npm version: 10.8.1

Shopify CLI version: 3.61.2

I even tried with Yarn but the error persists.

did you find the solution for this crypto error ?