JS error

Topic summary

  • Issue: On starting the local dev server, an error appears: “Cannot overwrite generated asset ‘assets/script.js’”, and the JS file doesn’t render locally. Uploading the same file directly to Shopify works.

  • Context: Custom theme; Shopify CLI (command-line interface) v3.50.2. The issue does not reproduce with Dawn (Shopify’s reference theme) initialized via shopify theme init, pointing to a theme-specific problem rather than a CLI bug.

  • Troubleshooting steps discussed:

    • Confirm whether the file is being edited.
    • Delete the JS asset in the Shopify Admin, pull the theme locally, then add the JS file back locally.
    • Test with a simple change (e.g., console.log) to see if the generation/overwrite issue persists.
  • Outcome: Following the delete-in-Admin → pull theme → re-add JS locally sequence fixed the problem. The JS file now works as expected.

  • Status: Resolved. Likely cause was a generated/locked asset state in the theme that blocked local overwrites; no further action needed.

Summarized with AI on January 11. AI used: gpt-5.

why do i get this when i start the server?
• 04:46:06 ERROR » update assets/script.js:
Cannot overwrite generated asset ‘assets/script.js’.

and this file isnt working / rendering, tho when i upload it directly to my shopify store, it works

Hi MohammadAL,

A few questions to help me troubleshoot this for you:

  • Are you making changes to this file?
  • If you delete this file manually on the admin and pull the theme, then add the JS file to the theme locally, is this working?
  • Is this a custom theme you’re working on or a theme someone else has developed?
  • If you try the same flow with Dawn by running shopify theme init are you experiencing the same error - if so it might be related to how the CLI is configured.
  • What version of the CLI are you using?

1- Yes
2- Yes, if I do that the JS file works
3- Yes, custom Theme
4- No, works perfectly
5- 3.50.2

Okay so it sounds like this is theme related rather than CLI related - it’s possible that there’s a change being made to the JS file that is not being accepted when you try to generate the theme. If you just make a simple change like a console.log is the error still appearing?

actually it got fixed, i did what u said, deleted it from admin, downloaded the theme then added the js file locally, and it worked, Thanks for your help :heart: