Shopify CLI error when calling "npm run dev"

Topic summary

Issue: Running “npm run dev” for a Shopify app fails with an error about reading an undefined “output” property, likely tied to build tooling or dependency issues.

Current state: Deleting node_modules in root, /web, and /web/frontend did not resolve it. The app previously worked; after attempting an update and then rolling back, the error persists. The developer prefers keeping a local Shopify CLI (per docs) rather than switching to a global install.

Suggested troubleshooting:

  • Check webpack.config.js or vite.config.js for invalid “output” references or undefined variables.
  • Review and align dependencies; run “npm ls” to spot version conflicts (e.g., react, react-dom, webpack) with the Shopify CLI version.
  • Clear build caches and artifacts (Vite’s .vite, Webpack cache, dist/build).
  • Verify environment variables across .env files.
  • Inspect the stack trace with verbose logging to pinpoint the failing module/file.
  • Create a minimal app via the local CLI and compare configurations.

Outcome: No resolution yet. Next step is reviewing config files; switching to a global CLI remains a fallback option. Discussion remains open.

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

My apologies, I just realised I posted this to the wrong board. I’ve reposted in the correct one, but can’t see an option to delete this post, so i’m editing it.

Many thanks

Mat

Hi Mat,

It looks like the error is due to trying to read an undefined ‘output’ property. Here are the top three likely causes:

  1. Dependency Mismatch: Version conflicts after updating Shopify CLI and other dependencies. Try deleting node_modules and reinstalling them. I am going to point to your node modules being they are listed several times.

  2. Configuration File Issues: Check your webpack.config.js or vite.config.js for any incorrect or outdated settings.

  3. Local vs. Global CLI Installation: Uninstall the local Shopify CLI and reinstall it globally to prevent conflicts.

    Edit: I would focus on one area at a time, to not break any code, I know how fickle things can be when you start changing the back end, I would focus on the simple stuff first, double checking things and seeing if there are any obvious conflicts. Make back ups before changing anything to not lose any progress so you can revert back if things go wrong.

Let me know how it goes!

Best regards,
Marc

Thanks for your response.

I did already try deleting node_modules in all 3 locations (root, /web and /web/frontend to no avail).

I checked the Shopify docs and although global installation is now the recommendation, there’s a section all about how to have a local installation instead and why you might do this, so I think it should be ok to have it local - it always worked until I tried to update, but then I rolled back and I get the same error.

I will check webpack.config.js and/or vite.config.js as you suggested before running a global install as I’d prefer to keep a local installation if possible.

Many thanks

Mat

Hi Mat,

I understand your preference to keep the CLI locally installed.

Since reinstalling node_modules didn’t help, here are some further steps to consider:

  1. Inspect Configuration Files
    Double-check webpack.config.js or vite.config.js for any references to output. Ensure all variables and objects are defined correctly, especially if you’ve updated dependencies recently.

  2. Review Dependencies
    Run npm ls to inspect the dependency tree and look for any version conflicts or missing packages that might be causing issues. It’s worth aligning critical packages like react, react-dom, or webpack to ensure they’re compatible with your Shopify CLI version.

  3. Clear Caches
    Try clearing any build caches (e.g., Vite’s .vite directory or Webpack’s cache) and remove old build artifacts (dist, build, etc.). This will force a clean build and eliminate potential conflicts.

  4. Verify Environment Variables
    Double-check your .env files to ensure all variables are correctly set and consistent across environments. An undefined environment variable could cause this error during build or runtime.

  5. Stack Trace Examination
    The stack trace might point to specific files or modules. Enable verbose logging in your build process to get more detailed insights into where the issue might lie.

  6. Minimal Reproduction
    As a last step, you could create a minimal app using the local Shopify CLI (shopify app create node) and compare its configuration files to spot any discrepancies.

Best regards,
Marc