Shopify CLI error when calling "npm run dev"

Shopify CLI error when calling "npm run dev"

Mat_Brummitt
Shopify Partner
52 1 15

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

Replies 3 (3)

Punlord_LLC
Tourist
7 0 1

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

Mat_Brummitt
Shopify Partner
52 1 15

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

Punlord_LLC
Tourist
7 0 1

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