cli: [Bug]: Execute Shopify theme dev with error message: request to xxx.theme.json?xxx processing failed, reason: read ETIMEDOUT

Please confirm that you have:

  • Searched existing issues to see if your issue is a duplicate. (If you’ve found a duplicate issue, feel free to add additional information in a comment on it.)
  • Reproduced the issue in the latest CLI version.

In which of these areas are you experiencing a problem?

Theme

Expected behavior

Start development services

Actual behavior

request to https://amirobeauty-com.myshopify.com/admin/api/unstable/themes │ │ .json?fields=id%2Cname%2Crole%2Cprocessing failed, reason: read ETIMEDOUT

Verbose output

2024-01-05T05:38:22.631Z: Running command theme dev
  shopify:theme:dev init version: @oclif/core@2.11.7 argv: [ '-t=162423603516', '-s=amirobeauty-com', '--verbose' ] +0ms
2024-01-05T05:38:22.653Z: Ensuring that the user is authenticated with the Theme API with the following scopes:
[]

2024-01-05T05:38:22.654Z: Ensuring that the user is authenticated with the Admin API with the following scopes for the store amirobeauty-com.myshopify.com:
[]

2024-01-05T05:38:22.654Z: Getting session store...
2024-01-05T05:38:22.658Z: Validating existing session against the scopes:
[
  "openid",
  "https://api.shopify.com/auth/shop.admin.graphql",
  "https://api.shopify.com/auth/shop.admin.themes",
  "https://api.shopify.com/auth/partners.collaborator-relationships.readonly",
  "https://api.shopify.com/auth/shop.storefront-renderer.devtools",
  "https://api.shopify.com/auth/partners.app.cli.access",
  "https://api.shopify.com/auth/destinations.readonly"
]
For applications:
{
  "adminApi": {
    "scopes": [],
    "storeFqdn": "amirobeauty-com.myshopify.com"
  }
}

2024-01-05T05:38:22.659Z: Sending Identity Introspection request to URL: https://accounts.shopify.com/oauth/introspection
2024-01-05T05:38:22.659Z: Sending POST request to URL https://accounts.shopify.com/oauth/introspection
With request headers:
 - User-Agent: Shopify CLI; v=3.51.2
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-01-05T05:38:23.347Z: Request to https://accounts.shopify.com/oauth/introspection completed in 674 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"1858cd7de013df56d8f94ed0f5bfefcc"
 - x-request-id: b87ed319-ea71-4e0c-92cc-0014e2c92be1
    
2024-01-05T05:38:23.359Z: The identity token is valid: true
2024-01-05T05:38:23.359Z: 
The validation of the token for application/identity completed with the following results:
- It's expired: false
- It's invalid in identity: false
  
2024-01-05T05:38:23.360Z: The current session is valid but needs refresh. Refreshing...
2024-01-05T05:38:23.364Z: Sending POST request to URL https://accounts.shopify.com/oauth/token?grant_type=refresh_token&access_token=atkn_CjQIoqverAYQwuPerAZSJggBEhCYyQfZG_FItoPH5HuDCJ8uGhDiMj-HiV1EsqpxTEMrCa8QEkDhw3xvxAMSewT92n5Cs1tTJfeGSkbr7EKZWb9_rk_Dbm25Afg5T8Sn3Cyhq8mPHq4XlH4AELwGJiX_LJ-FybwB&refresh_token=atkn_CiEIoqverAYQosX8rQaiARIKEOIyP4eJXUSyqnFMQysJrxASQGpA8QjIt_Eb1oH-IrlAeS_2dK7_oHw56fEQwjdaiZT-XH2dY53UukzAQTaAmdVcH7sqpAwu0DFmkswjENVEAgI&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3
With request headers:
 - User-Agent: Shopify CLI; v=3.51.2
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-01-05T05:38:24.051Z: Request to https://accounts.shopify.com/oauth/token?grant_type=refresh_token&access_token=atkn_CjQIoqverAYQwuPerAZSJggBEhCYyQfZG_FItoPH5HuDCJ8uGhDiMj-HiV1EsqpxTEMrCa8QEkDhw3xvxAMSewT92n5Cs1tTJfeGSkbr7EKZWb9_rk_Dbm25Afg5T8Sn3Cyhq8mPHq4XlH4AELwGJiX_LJ-FybwB&refresh_token=atkn_CiEIoqverAYQosX8rQaiARIKEOIyP4eJXUSyqnFMQysJrxASQGpA8QjIt_Eb1oH-IrlAeS_2dK7_oHw56fEQwjdaiZT-XH2dY53UukzAQTaAmdVcH7sqpAwu0DFmkswjENVEAgI&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3 completed in 682 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"7aea3781ee472647f2dd168c9546b2d5"
 - x-request-id: ff1e2970-b8df-4b8f-8f6b-e1fcb5c361c4
    
2024-01-05T05:38:24.059Z: Sending POST request to URL https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=271e16d403dfa18082ffb3d197bd2b5f4479c3fc32736d69296829cbb28d41a6&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.app.cli.access&subject_token=****
With request headers:
 - User-Agent: Shopify CLI; v=3.51.2
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-01-05T05:38:24.059Z: Sending POST request to URL https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=ee139b3d-5861-4d45-b387-1bc3ada7811c&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshop.storefront-renderer.devtools&subject_token=****
With request headers:
 - User-Agent: Shopify CLI; v=3.51.2
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-01-05T05:38:24.059Z: Sending POST request to URL https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=32ff8ee5-82b8-4d93-9f8a-c6997cefb7dc&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fdestinations.readonly&subject_token=****
With request headers:
 - User-Agent: Shopify CLI; v=3.51.2
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-01-05T05:38:24.059Z: Sending POST request to URL https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshop.admin.graphql+https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshop.admin.themes+https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.collaborator-relationships.readonly&subject_token=****&destination=https%3A%2F%2Famirobeauty-com.myshopify.com%2Fadmin
With request headers:
 - User-Agent: Shopify CLI; v=3.51.2
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-01-05T05:38:24.715Z: Request to https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=ee139b3d-5861-4d45-b387-1bc3ada7811c&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshop.storefront-renderer.devtools&subject_token=**** completed in 646 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"0aafaab49c7da130c0eb9b2c2b4531bb"
 - x-request-id: 0c4d9712-b5cc-48b1-a756-4cdfb2ec977a
    
2024-01-05T05:38:24.727Z: Request to https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=271e16d403dfa18082ffb3d197bd2b5f4479c3fc32736d69296829cbb28d41a6&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.app.cli.access&subject_token=**** completed in 661 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"ef12c0211829f8adabc1f8140f9696f6"
 - x-request-id: f0ef61a5-c596-460b-9fef-4e0487168404
    
2024-01-05T05:38:24.733Z: Request to https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshop.admin.graphql+https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshop.admin.themes+https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.collaborator-relationships.readonly&subject_token=****&destination=https%3A%2F%2Famirobeauty-com.myshopify.com%2Fadmin completed in 657 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"43ebc473530be7e146a89f7ed544ec75"
 - x-request-id: d9e5070d-9c69-428f-bfd6-5cb3631afff7
    
2024-01-05T05:38:24.743Z: Request to https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=32ff8ee5-82b8-4d93-9f8a-c6997cefb7dc&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fdestinations.readonly&subject_token=**** completed in 672 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"ad972dff4f4847856b336befe6d77749"
 - x-request-id: 78d4eea6-e423-4f26-87fa-3b3a77dfcbd4
    
2024-01-05T05:38:24.746Z: Setting session store...
2024-01-05T05:38:24.754Z: Ensuring that the user is authenticated with the Storefront API with the following scopes:
[]

2024-01-05T05:38:24.755Z: Getting session store...
2024-01-05T05:38:24.758Z: Validating existing session against the scopes:
[
  "openid",
  "https://api.shopify.com/auth/shop.admin.graphql",
  "https://api.shopify.com/auth/shop.admin.themes",
  "https://api.shopify.com/auth/partners.collaborator-relationships.readonly",
  "https://api.shopify.com/auth/shop.storefront-renderer.devtools",
  "https://api.shopify.com/auth/partners.app.cli.access",
  "https://api.shopify.com/auth/destinations.readonly"
]
For applications:
{
  "storefrontRendererApi": {
    "scopes": []
  }
}

2024-01-05T05:38:24.758Z: Sending Identity Introspection request to URL: https://accounts.shopify.com/oauth/introspection
2024-01-05T05:38:24.758Z: Sending POST request to URL https://accounts.shopify.com/oauth/introspection
With request headers:
 - User-Agent: Shopify CLI; v=3.51.2
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-01-05T05:38:25.385Z: Request to https://accounts.shopify.com/oauth/introspection completed in 624 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"4c322ab9b3ca704742af61217c25bba1"
 - x-request-id: 5e2fe173-6ac8-46f9-9f02-1fdf0df387c4
    
2024-01-05T05:38:25.389Z: The identity token is valid: true
2024-01-05T05:38:25.389Z: 
The validation of the token for application/identity completed with the following results:
- It's expired: false
- It's invalid in identity: false
  
2024-01-05T05:38:25.406Z: 
Running system process:
  · Command: /usr/local/opt/ruby/bin/ruby -v
  · Working directory: /Users/baymax/Desktop/vscode/amiro

2024-01-05T05:38:25.457Z: 
Running system process:
  · Command: /usr/local/opt/ruby/bin/bundle -v
  · Working directory: /Users/baymax/Desktop/vscode/amiro

2024-01-05T05:38:25.601Z: Reading the content of file at /usr/local/Cellar/shopify-cli/3.51.2/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/assets/cli-ruby/Gemfile...
2024-01-05T05:38:25.603Z: 
Running system process:
  · Command: /usr/local/opt/ruby/bin/bundle install
  · Working directory: /usr/local/Cellar/shopify-cli/3.51.2/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/assets/cli-ruby

2024-01-05T05:38:25.871Z: 
Running system process:
  · Command: /usr/local/opt/ruby/bin/bundle exec /usr/local/opt/ruby/bin/ruby /usr/local/Cellar/shopify-cli/3.51.2/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/assets/cli-ruby/bin/shopify theme token --admin atkn_Cp8DCNCr3qwGEPDj3qwGYpADCAESEDKFuqv6eUvGgCTwcNV671oaqAFodHRwczovL2FwaS5zaG9waWZ5LmNvbS9hdXRoL3BhcnRuZXJzLmNvbGxhYm9yYXRvci1yZWxhdGlvbnNoaXBzLnJlYWRvbmx5IGh0dHBzOi8vYXBpLnNob3BpZnkuY29tL2F1dGgvc2hvcC5hZG1pbi5ncmFwaHFsIGh0dHBzOi8vYXBpLnNob3BpZnkuY29tL2F1dGgvc2hvcC5hZG1pbi50aGVtZXMgDSinUzIQkRrMQBltTVu_byZGZKBDTTokNDA3ZWJkZGEtYzMwYS00NzJmLWFiY2ItZTUxNjYzOGI0ODkwQgdBY2NvdW50ShD_L62KA95L8bcf54Lwf0LXUlN7InN1YiI6ImZiZGIyNjQ5LWUzMjctNDkwNy04ZjY3LTkwOGQyNGNmZDdlMyIsImlzcyI6Imh0dHBzOi8vYWNjb3VudHMuc2hvcGlmeS5jb20ifWIQ9JXN4zO-R9GN8r5UoxH4y2oQxuZkRHl4TiGQyRrakuDGnRJA7BSSeOZBgt3pX2uRbSlMZWRhPDXNtew5xr-GHR947i6XacxmhCd29bvZvjCCMUK5ITO4sZd5Nmd7T7-jHyITCw --sfr atkn_CqMCCNCr3qwGEPDj3qwGYpQCCAESEJHDg4xstkAyqcNyOeN39kwaPmh0dHBzOi8vYXBpLnNob3BpZnkuY29tL2F1dGgvc2hvcC5zdG9yZWZyb250LXJlbmRlcmVyLmRldnRvb2xzINhSKKdTOiQ0MDdlYmRkYS1jMzBhLTQ3MmYtYWJjYi1lNTE2NjM4YjQ4OTBCB0FjY291bnRKEP8vrYoD3kvxtx_ngvB_QtdSU3sic3ViIjoiZmJkYjI2NDktZTMyNy00OTA3LThmNjctOTA4ZDI0Y2ZkN2UzIiwiaXNzIjoiaHR0cHM6Ly9hY2NvdW50cy5zaG9waWZ5LmNvbSJ9YhD0lc3jM75H0Y3yvlSjEfjLahDG5mREeXhOIZDJGtqS4MadEkB7cD3vJ8X7oTOigcu1q4FOKSxt_rj2N-gcY26uMNYeRzgbELqsfnl5MeiWLRAXZRwVyrZRt63WnwQtzNoq-mwA
  · Working directory: /Users/baymax/Desktop/vscode/amiro

2024-01-05T05:41:30.960Z: Request to https://amirobeauty-com.myshopify.com/admin/api/unstable/themes.json?fields=id%2Cname%2Crole%2Cprocessing completed in 184652 ms
With response headers:

    
╭─ error ──────────────────────────────────────────────────────────────────────╮
│                                                                              │
│  request to https://amirobeauty-com.myshopify.com/admin/api/unstable/themes  │
│  .json?fields=id%2Cname%2Crole%2Cprocessing failed, reason: read ETIMEDOUT   │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

2024-01-05T05:41:31.056Z: Unable to log analytics event - no information on executed command
2024-01-05T05:41:31.063Z: Reporting handled error to Bugsnag: request to https://amirobeauty-com.myshopify.com/admin/api/unstable/themes.json?fields=id%2Cname%2Crole%2Cprocessing failed, reason: read ETIMEDOUT
2024-01-05T05:41:31.088Z: Obtaining the dependency manager in directory /Users/baymax/Desktop/vscode/amiro...
    FetchError: request to 
    https://amirobeauty-com.myshopify.com/admin/api/unstable/themes.json?fields=id%2Cname%2Crole%2Cprocessing failed, 
    reason: read ETIMEDOUT
    Code: ETIMEDOUT

Reproduction steps

shopify theme dev -t=162423603516 -s=amirobeauty-com --verbose

Operating System

macOS Sonoma 14.1.2

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

3.51.2

Shell

zsh

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

v21.4.0

What language and version are you using in your application?

No response

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Comments: 55

Most upvoted comments

Find some wrong things, This problem caused by country firewall , in some country (cn), you can’t visit shopify resource now, after 1.4 or 1.5 of 2024 . by view shopify cli core code , it’s use oclif/core package of npm to run cli command , and send some api requests by node-fetch lib, but node-fetch cannot proxy terminal requests auto, even you has open some proxy node to view shopify, so just wait shopify cli update , or change the cli core code to proxy request! for every one , the issue has bothered me all day…

----------------------------240106 update

Yes, I’m sure the answer is right above, after test ,

Suggest Shopify CLI add --proxy and alias -p option for command option, or use terminal http_proxy or https_proxy directly, we will use proxy self!

This problem has been temporarily solved, and I feel a little more relaxed now. I can’t imagine how painful it will be if you can’t use shopify for local development.

目前我有两个方法让网络没问题

  1. VPN软件使用TUN模式

  2. 把@shopify/cli 替换成 @hankts/shopify-cli 使用这个方法需要在环境变量里设置http_proxy,我fork的包是通过判断环境变量来决定是否走代理。

给大家写下具体步骤

完整Shopify-cli代理设置步骤

Step1: 确认文件位置

例如我是使用 brew 安装的,可以通过 brew list shopify-cli 确认Shopify-cli 文件位置

baymax@chouyaofandedeMacBook-Pro remix-shopify % brew list shopify-cli
/usr/local/Cellar/shopify-cli/3.53.0/bin/shopify
/usr/local/Cellar/shopify-cli/3.53.0/libexec/bin/ (2 files)
/usr/local/Cellar/shopify-cli/3.53.0/libexec/lib/ (57641 files)

Step2: 进入theme@shopify/cli-kit 中安装 https-proxy-agent

例如我的完整路径 node_modules/@shopify/theme/node_modules/@shopify/cli-kit, 如果你要用theme 外其他命令,还需要修改 cli 中的@shopify/cli-kit

安装 https-proxy-agent

npm install https-proxy-agent

Step3: 修改 dist/public/node/http.js 文件中的fetch 函数

import { HttpsProxyAgent } from "https-proxy-agent";

export async function fetch(url, init) {
  // 可以保留 console.log("fetching: Proxy"); 以确认你修改的路径是否正确
  console.log("fetching: Proxy");
  // 可以用变量,也可以直接写代理地址
  // const proxy_url = process.env.HTTP_PROXY || process.env.HTTPS_PROXY; 
  const proxy_url = "http://127.0.0.1:10010";
  const agent = new HttpsProxyAgent(proxy_url);
  return runWithTimer("cmd_all_timing_network_ms")(() =>
    debugLogResponseInfo({
      url: url.toString(),
      request: nodeFetch(url, { ...init, agent }),
    })
  );
}

÷

@MyBaymax , @Shenr1 do a temporarily resolve plan, make these change :

in your global npm/yarn/pnpm package directory, find the package path: node_modules/@shopify/cli-kit/dist/public/node/http.js

then:

export async function fetch(url, init) { console.log(‘termial proxy’) const proxy_url = process.env.HTTP_PROXY || process.env.HTTPS_PROXY; const agent = new HttpsProxyAgent(proxy_url) return runWithTimer(‘cmd_all_timing_network_ms’)(() => debugLogResponseInfo({ url: url.toString(), request: nodeFetch(url, { …init, agent }) })); }

before add agent to node-fetch, please make sure install https-proxy-agent package global installed, have fun day!

给大家写下具体步骤

完整Shopify-cli代理设置步骤

Step1: 确认文件位置

例如我是使用 brew 安装的,可以通过 brew list shopify-cli 确认Shopify-cli 文件位置

baymax@chouyaofandedeMacBook-Pro remix-shopify % brew list shopify-cli
/usr/local/Cellar/shopify-cli/3.53.0/bin/shopify
/usr/local/Cellar/shopify-cli/3.53.0/libexec/bin/ (2 files)
/usr/local/Cellar/shopify-cli/3.53.0/libexec/lib/ (57641 files)

Step2: 进入theme@shopify/cli-kit 中安装 https-proxy-agent

例如我的完整路径 node_modules/@shopify/theme/node_modules/@shopify/cli-kit, 如果你要用theme 外其他命令,还需要修改 cli 中的@shopify/cli-kit

安装 https-proxy-agent

npm install https-proxy-agent

Step3: 修改 dist/public/node/http.js 文件中的fetch 函数

import { HttpsProxyAgent } from "https-proxy-agent";

export async function fetch(url, init) {
  // 可以保留 console.log("fetching: Proxy"); 以确认你修改的路径是否正确
  console.log("fetching: Proxy");
  // 可以用变量,也可以直接写代理地址
  // const proxy_url = process.env.HTTP_PROXY || process.env.HTTPS_PROXY; 
  const proxy_url = "http://127.0.0.1:10010";
  const agent = new HttpsProxyAgent(proxy_url);
  return runWithTimer("cmd_all_timing_network_ms")(() =>
    debugLogResponseInfo({
      url: url.toString(),
      request: nodeFetch(url, { ...init, agent }),
    })
  );
}

÷

what is runWithTimer?

shopify

@tedjsmeng 完整的路径如下

/node_modules/@shopify/cli/node_modules/@shopify/cli-kit/dist/public/node/http.js
/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/dist/public/node/http.js

image

然后点击左下角启动按钮,这样你的网路就可以代理模式,你在使用shopify theme dev 或者shopify theme push 就没问题了。其实就是要一个好代理。希望能帮到大家。

image

不想麻烦的用这个方法就可以了,小白适合,也不要那么麻烦改代码什么之类的,只需要开启代理即可。谢谢。纯属被shopify 这几天气死了才发布这个简单的教程。如果提示添加环境变量 你就需要添加下环境变量 image

不需要那么复杂去改来改去的,还改什么代码对于新手来说太麻烦。简而言之,就是你用一个好点的VPN代理就可以了,还有就是代理软件的问题,我会把我的步骤放下面,我也困惑了好几天,找了很多资料,也找了shopify客服也没解决。后来自己换一个代理软件就可以了。

  1. 9158cloud 可以用他们家的VPN 25人民币一个月很良心,是真正的IPLC线路香港速度非常快 不管你shopify theme dev 还是push都没问题很快。 可能有的小伙伴会问,为什么你用了VPN也无法正常push 或者dev,一个是代理节点问题或者代理软件问题。我自己用的是webstrom 和VSC调试软件,不需要单独去软件开http proxy。你只需要下载一个代理软件1.无需翻墙下载netch下载密码:91582.翻墙加速下载备用软件

I am using vpn proxy, http proxy local port is 10808 LAN port is 10810, no environment variables are set, here is the code I changed: 屏幕截图 2024-01-09 110349 Is something misconfigured?

@MyBaymax @Shenr1 we fixed it by C-l-a-s-hX (advanced mode) and run the terminal command to set https_proxy and http_proxy, but now it seems the repository has gone. So I just suggest you can try the @forwells supplied solution, if still have some issue, please give me private message.