Shopify / cli

Build apps, themes, and hydrogen storefronts for Shopify
https://shopify.dev
MIT License
379 stars 112 forks source link

[Bug]: Cannot use shopify theme dev #3489

Open NathKaden opened 4 months ago

NathKaden commented 4 months ago

Please confirm that you have:

In which of these areas are you experiencing a problem?

Theme

Expected behavior

Run shopify theme dev --store (mystore).myshopify.com command and access to my website with local developpement and have automatically refresh after a save on my IDE.

Actual behavior

After type shopify theme dev --store (mystore).myshopify.com I have the error on the verbose output; Even if I delete the file on C:\Users\%USERNAME%\AppData\Roaming\shopify-cli-kit-nodejs\Config I have the same issue after connexion and type the command. Same issue with shopify theme dev Sometimes, the verbose say "✔ Logged in." but nothing happends..

Verbose output

╭─ error ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                    │
│  Cannot read properties of undefined (reading 'toString')                                                                          │
│                                                                                                                                    │
│  To investigate the issue, examine this stack trace:                                                                               │
│    at create (../../AppData/Roaming/npm/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/src/public/node/themes/theme-ma  │
│    nager.ts:48)                                                                                                                    │
│      this.setTheme(theme.id.toString())                                                                                            │
│    at processTicksAndRejections (node:internal/process/task_queues:95)                                                             │
│    at findOrCreate (../../AppData/Roaming/npm/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/src/public/node/themes/th  │
│    eme-manager.ts:19)                                                                                                              │
│      theme = await this.create()                                                                                                   │
│    at run (../../AppData/Roaming/npm/node_modules/@shopify/theme/src/cli/commands/theme/dev.ts:127)                                │
│      const theme = await new DevelopmentThemeManager(adminSession).findOrCreate()                                                  │
│    at async runCLI (../../AppData/Roaming/npm/node_modules/@shopify/cli/node_modules/@shopify/cli-kit/src/public/node/cli.ts:88)   │
│      await run(undefined, options.moduleURL)                                                                                       │
│    at async runShopifyCLI (../../AppData/Roaming/npm/node_modules/@shopify/cli/src/index.ts:42)                                    │
│      await runCLI({                                                                                                                │
│                                                                                                                                    │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

    TypeError: Cannot read properties of undefined (reading 'toString')

Reproduction steps

  1. Run shopify theme dev --store=(thestore).myshopify.com

Operating System

Win 11

Shopify CLI version (check your project's package.json if you're not sure)

3.56.3

Shell

Shell of VSCode or tried PhpStorm

Node version (run node -v if you're not sure)

v21.6.1

What language and version are you using in your application?

ruby 3.2.2, liquid, css

luhaimin commented 4 months ago

I have already run it, my steps do not need to delete config.json shopify auth logout shopify theme dev --store=xxxxx.myshopify.com

I haven't added -- store before, but adding -- store will run normally

crossandborder commented 4 months ago

Encountering the same problem

╭─ error ──────────────────────────────────────────────────────────────────────╮ │
│ Cannot read properties of undefined (reading 'toString')

│ To investigate the issue, examine this stack trace:
│ at create (../../../../Users/.../AppData/Local/pnpm/global/5/.pnpm/@sh
│ opify+cli-kit@3.56.3_typescript@5.3.3/node_modules/@shopify/cli-kit/src/
│ public/node/themes/theme-manager.ts:48)
│ this.setTheme(theme.id.toString())
│ at processTicksAndRejections (node:internal/process/task_queues:95)
│ at findOrCreate (../../../../Users/.../AppData/Local/pnpm/global/5/.pn
│ pm/@shopify+cli-kit@3.56.3_typescript@5.3.3/node_modules/@shopify/cli-ki
│ t/src/public/node/themes/theme-manager.ts:19)
│ theme = await this.create()
│ at run (../../../../Users/.../AppData/Local/pnpm/global/5/.pnpm/@shopi
│ fy+theme@3.56.3_typescript@5.3.3/node_modules/@shopify/theme/src/cli/com
│ mands/theme/dev.ts:127)
│ const theme = await new
│ DevelopmentThemeManager(adminSession).findOrCreate()
│ at async runCLI (../../../../Users/.../AppData/Local/pnpm/global/5/.pn
│ pm/@shopify+cli-kit@3.56.3_typescript@5.3.3/nodemodules/@shopify/cli-ki
│ t/src/public/node/cli.ts:88)
│ await run(undefined, options.moduleURL)
│ at async runShopifyCLI (../../../../Users/.../AppData/Local/pnpm/globa
│ l/5/.pnpm/@shopify+cli@3.56.3
@types+node@20.11.20_typescript@5.3.3_zod@
│ 3.22.4/node_modules/@shopify/cli/src/index.ts:42)
│ await runCLI({

╰─────────────────────────────────────────────────────────────────────────────

wjc133 commented 4 months ago

Encountering the same problem, and delete shopify-cli-kit-nodejs/config.json didn't work.

✔ Logged in.
╭─ error ──────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                      │
│  Cannot read properties of undefined (reading 'toString')                                            │
│                                                                                                      │
│  To investigate the issue, examine this stack trace:                                                 │
│    at create (../../../../../../opt/homebrew/Cellar/shopify-cli/3.56.3/libexec/lib/node_modules/@sh  │
│    opify/theme/node_modules/@shopify/cli-kit/src/public/node/themes/theme-manager.ts:48)             │
│      this.setTheme(theme.id.toString())                                                              │
│    at processTicksAndRejections (node:internal/process/task_queues:95)                               │
│    at findOrCreate (../../../../../../opt/homebrew/Cellar/shopify-cli/3.56.3/libexec/lib/node_modul  │
│    es/@shopify/theme/node_modules/@shopify/cli-kit/src/public/node/themes/theme-manager.ts:19)       │
│      theme = await this.create()                                                                     │
│    at run (../../../../../../opt/homebrew/Cellar/shopify-cli/3.56.3/libexec/lib/node_modules/@shopi  │
│    fy/theme/src/cli/commands/theme/dev.ts:127)                                                       │
│      const theme = await new DevelopmentThemeManager(adminSession).findOrCreate()                    │
│    at async runCLI (../../../../../../opt/homebrew/Cellar/shopify-cli/3.56.3/libexec/lib/node_modul  │
│    es/@shopify/cli/node_modules/@shopify/cli-kit/src/public/node/cli.ts:88)                          │
│      await run(undefined, options.moduleURL)                                                         │
│    at async runShopifyCLI (../../../../../../opt/homebrew/Cellar/shopify-cli/3.56.3/libexec/lib/nod  │
│    e_modules/@shopify/cli/src/index.ts:42)                                                           │
│      await runCLI({                                                                                  │
│                                                                                                      │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯
aydinvivik commented 2 months ago

I installed Shopify for the first time but I have the same problem.

ruby: 3.3.0 node: 20.12.2 MacOS Sonoma

╭─ error ───────────────────────────────────────────────────────────────────────────╮
│                                                                                   │
│  Cannot read properties of undefined (reading 'toString')                         │
│                                                                                   │
│  To investigate the issue, examine this stack trace:                              │
│    at create (usr/local/lib/node_modules/@shopify/cli/dist/index.js:195941)       │
│    at processTicksAndRejections (node:internal/process/task_queues:95)            │
│    at findOrCreate                                                                │
│    (usr/local/lib/node_modules/@shopify/cli/dist/index.js:195914)                 │
│    at run (usr/local/lib/node_modules/@shopify/cli/dist/index.js:204557)          │
│    at _run                                                                        │
│    (usr/local/lib/node_modules/@shopify/cli/dist/chunk-3MMF34G4.js:212317)        │
│    at runCommand                                                                  │
│    (usr/local/lib/node_modules/@shopify/cli/dist/chunk-3MMF34G4.js:210764)        │
│    at run                                                                         │
│    (usr/local/lib/node_modules/@shopify/cli/dist/chunk-3MMF34G4.js:212426)        │
│    at async runCLI                                                                │
│    (usr/local/lib/node_modules/@shopify/cli/dist/index.js:194855)                 │
│    at async runShopifyCLI                                                         │
│    (usr/local/lib/node_modules/@shopify/cli/dist/index.js:207961)                 │
│                                                                                   │
╰───────────────────────────────────────────────────────────────────────────────────╯

    TypeError: Cannot read properties of undefined (reading 'toString')
cchampou commented 2 months ago

Same issue here, node 20.11.1, MacOS Sonoma (ARM), Ruby 3.3.1

cchampou commented 2 months ago

Same issue here, node 20.11.1, MacOS Sonoma (ARM), Ruby 3.3.1

On my side, the issue was due to invalid store URL. I though of using the name of the store and then concatenate .myshopify.com, which is wrong. I figured out the correct URL through domain section in the admin.

I think this can still be considered as an issue, a comprehensive error message would be much appreciated for such scenario.

The issue is happening with this version

@shopify/cli/3.59.1 darwin-arm64 node-v18.19.1
github-actions[bot] commented 1 month ago

This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. → If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's dev tooling and experience.

P.S. You can learn more about why we stale issues here.

lukeh-shopify commented 3 weeks ago

👋🏻 Hi @NathKaden - thanks for raising this issue! Would you mind re-running the command with --verbose at the end of it and sharing the output here? Anyone else running into this issue can do the same. Thanks!

AdinaSchustal commented 1 week ago

Encountering this error for a specific store while it works properly for other stores. Deleting shopify-cli-kit-nodejs/config.json didn't work.

✔ Logged in. ╭─ error ────────────────────────────────────────────────────────────────────────────────────────────────╮ │ │ │ Cannot read properties of undefined (reading 'toString') │ │ │ │ To investigate the issue, examine this stack trace: │ │ at create (Users/adina/AppData/Roaming/npm/node_modules/@shopify/cli/dist/index.js:193708) │ │ at processTicksAndRejections (node:internal/process/task_queues:95) │ │ at findOrCreate (Users/adina/AppData/Roaming/npm/node_modules/@shopify/cli/dist/index.js:193681) │ │ at run (Users/adina/AppData/Roaming/npm/node_modules/@shopify/cli/dist/index.js:195224) │ │ at _run (Users/adina/AppData/Roaming/npm/node_modules/@shopify/cli/dist/chunk-GEN4RXTD.js:209983) │ │ at runCommand │ │ (Users/adina/AppData/Roaming/npm/node_modules/@shopify/cli/dist/chunk-GEN4RXTD.js:208416) │ │ at run (Users/adina/AppData/Roaming/npm/node_modules/@shopify/cli/dist/chunk-GEN4RXTD.js:210097) │ │ at async runCLI (Users/adina/AppData/Roaming/npm/node_modules/@shopify/cli/dist/index.js:192823) │ │ at async runShopifyCLI │ │ (Users/adina/AppData/Roaming/npm/node_modules/@shopify/cli/dist/index.js:223114) │ │ │ ╰─────────────────────────────────────────────────────────────────────────────

jamesmengo commented 4 days ago

For those experiencing this issue, please 1) share verbose logs in addition to the error that you are receiving. I've provided a snippet below of what the beginning of the verbose logs should look like 2) run shopify theme list on the store in question and share the output here (no need for verbose)

❯ shopify theme dev --verbose
2024-07-05T17:18:28.301Z: Running command theme dev
2024-07-05T17:18:28.310Z: Ensuring that the user is authenticated with the Theme API with the following scopes:
[]

2024-07-05T17:18:28.311Z: Ensuring that the user is authenticated with the Admin API with the following scopes for the store quickstart-b88db4f0.myshopify.com:
[]