Shopify / slate

Slate is a toolkit for developing Shopify themes. It's designed to assist your workflow and speed up the process of developing, testing, and deploying themes.
https://shopify.github.io/slate
MIT License
1.28k stars 364 forks source link

slate migrate triggers SyntaxError #1053

Closed alex-espinoza closed 4 years ago

alex-espinoza commented 4 years ago

Problem

Haven't had an issue with the slate migrate command until today. Using slate 0.14.

Full error output:

Warning! This will change your theme's folder structure. Are you sure you want to proceed? Yes

  ✔ Your theme is a valid Shopify theme

  ✔ Migration checks completed

  Starting migration...

  Migrating assets to src/...
  Migrating config to src/...
  Migrating layout to src/...
  Migrating locales to src/...
  Migrating sections to src/...
  Migrating snippets to src/...
  Migrating templates to src/...
(node:37355) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token / in JSON at position 2980
    at JSON.parse (<anonymous>)
    at /usr/local/lib/node_modules/@shopify/slate/lib/utils.js:203:54
    at new Promise (<anonymous>)
    at Object.unminifyJson (/usr/local/lib/node_modules/@shopify/slate/lib/utils.js:200:10)
    at unminifyJsonPromiseFactory (/usr/local/lib/node_modules/@shopify/slate/lib/commands/migrate.js:19:30)
    at Array.map (<anonymous>)
    at Object._callee$ (/usr/local/lib/node_modules/@shopify/slate/lib/commands/migrate.js:105:53)
    at tryCatch (/usr/local/lib/node_modules/@shopify/slate/node_modules/regenerator-runtime/runtime.js:63:40)
    at Generator.invoke [as _invoke] (/usr/local/lib/node_modules/@shopify/slate/node_modules/regenerator-runtime/runtime.js:337:22)
    at Generator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/@shopify/slate/node_modules/regenerator-runtime/runtime.js:96:21)
(node:37355) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:37355) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

  ✔ Migration to src/ completed

  SyntaxError: Unexpected token / in JSON at position 2980

  ✖ Migration failed. Please check src/ directory

(node:37355) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)

Replication steps

Use downloaded theme files extracted from the zip generated from the Shopify 'Download theme file' button. Run the slate migrate inside the directory.

More Information

Using:

npm 6.9.0 node v10.16.3

Tried un-installing and re-installing node, npm, and slate. Hasn't fixed the issue. slate watch seems to be working fine.

builtbylane commented 4 years ago

@lex-espinoza one of your config/*.json files likely has invalid JSON in it.

If that doesn't help, you can debug by adding console.log('asset', asset.toString()); to /node_modules/@shopify/slate-tag-webpack-plugin/index.js:11 and print out the json before the process crashes

alex-espinoza commented 4 years ago

Thanks @builtbylane - fixing that invalid JSON solved the issue.

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.