Cannot use --host on Shopify CLI

Is anyone else having issues using --host tag with “npm run dev – --host”?

This is the command I ran:

npm run dev -- --host

And this is the response:

> ****@2025.1.2 dev
> shopify hydrogen dev --codegen

WARNING: NPM scripts require an extra `--` separator to pass the flags.  Example: `npm run dev -- --reset` 

Normally this works, but this morning I tried and it won’t host. Just gives me a warning to use an extra --

1 Like

Hey @Drew :waving_hand: - if you’re still seeing this issue pop up, could you try running this in your CLI:

shopify hydrogen dev --codegen --host --verbose

Just want to see if running both commands resolves the issue, and if not, I can take a look at the verbose logs if you can share them in this thread to see if we can narrow down the issue.

Yes, I ran this command and this is what it logged:

PS D:\******\HYDROGEN\******-v3> shopify hydrogen dev --codegen --host --verbose
2025-05-12T16:32:28.194Z: Running command hydrogen dev
2025-05-12T16:32:28.201Z: Notifications to show: 0
2025-05-12T16:32:28.215Z: Reading the .env file at .env
2025-05-12T16:32:28.215Z: Reading the content of file at .env...
2025-05-12T16:32:28.229Z: 
Running system process:
  · Command: npm prefix
  · Working directory: D:\******\HYDROGEN\******-v3

2025-05-12T16:32:28.231Z: Reading the content of file at node_modules/vite/package.json...
2025-05-12T16:32:28.232Z: Reading the content of file at .shopify/project.json...
╭─ error ───────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                               │
│  Directory import 'D:\******\HYDROGEN\******-v3\node_modules\vite' is not supported resolving ES        │
│  modules imported from C:\Users\******\AppData\Roaming\npm\node_modules\@shopify\cli\dist\chunk-DV2H7WDY.js    │
│  Did you mean to import "file:///D:/******/HYDROGEN/******-v3/node_modules/vite/dist/node/index.js"?  │
│                                                                                                               │
│  To investigate the issue, examine this stack trace:                                                          │
│    at Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import 'D:\******                                           │
│    \HYDROGEN\******-v3\node_modules\vite' is not supported resolving ES modules imported from          │
│    C:\Users\******\AppData\Roaming\npm\node_modules\                                                           │
│    at finalizeResolution (node:internal/modules/esm/resolve:263)                                              │
│    at moduleResolve (node:internal/modules/esm/resolve:932)                                                   │
│    at defaultResolve (node:internal/modules/esm/resolve:1056)                                                 │
│    at defaultResolve (node:internal/modules/esm/loader:654)                                                   │
│    at #cachedDefaultResolve (node:internal/modules/esm/loader:603)                                            │
│    at resolve (node:internal/modules/esm/loader:586)                                                          │
│    at getModuleJobForImport (node:internal/modules/esm/loader:242)                                            │
│    at __proto__ (node:diagnostics_channel:344)                                                             │
│    at tracePromise (node:diagnostics_channel:344)                                                             │
│    at import (node:internal/modules/esm/loader:545)                                                           │
│                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

2025-05-12T16:32:28.342Z: 
Running system process:
  · Command: npm prefix
  · Working directory: D:/******/HYDROGEN/******-v3

2025-05-12T16:32:28.342Z: Reading the content of file at .shopify/project.json...
2025-05-12T16:32:28.343Z: Ensuring that the user is authenticated with the Admin API with the following scopes for the store *******.myshopify.com:      
[]

2025-05-12T16:32:28.344Z: Getting session store...
2025-05-12T16:32:28.345Z: 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",
  "https://api.shopify.com/auth/organization.store-management",
  "https://api.shopify.com/auth/organization.apps.manage"
]
For applications:
{
  "adminApi": {
    "scopes": [],
    "storeFqdn": "*******.myshopify.com"
  }
}

2025-05-12T16:32:28.346Z: - Token validation -> It's expired: false
2025-05-12T16:32:28.346Z: Sending GET request to URL https://accounts.shopify.com/.well-known/openid-configuration.json
With request headers:
 - User-Agent: Shopify CLI; v=3.75.0
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: win32
 - Content-Type: application/json

2025-05-12T16:32:28.427Z: Obtaining the dependency manager in directory D:\******\HYDROGEN\******-v3...
2025-05-12T16:32:28.530Z: Obtaining the dependency manager in directory D:\******\HYDROGEN\******-v3...
2025-05-12T16:32:28.719Z: Getting session store...
2025-05-12T16:32:28.723Z: Request to https://accounts.shopify.com/.well-known/openid-configuration.json completed in 376 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/"1df259518dad2ec46357701b4c73e065"
 - server-timing: processing;dur=12, socket_queue;dur=2.192, edge;dur=2.052, util;dur=0.1, cfRequestDuration;dur=187.000036
 - x-request-id: ******-****-****-****-************

2025-05-12T16:32:28.724Z: Getting session store...
2025-05-12T16:32:28.739Z: Sending Identity Introspection request to URL: https://accounts.shopify.com/oauth/introspection
2025-05-12T16:32:28.739Z: Sending POST request to URL https://accounts.shopify.com/oauth/introspection
With request headers:
 - User-Agent: Shopify CLI; v=3.75.0
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: win32
 - Content-Type: application/json

2025-05-12T16:32:28.865Z: Request to https://monorail-edge.shopifysvc.com/v1/produce completed in 137 ms
With response headers:
 - x-request-id: ******-****-****-****-************

2025-05-12T16:32:28.866Z: Analytics event sent: {
  "command": "hydrogen dev",
  "time_start": 1747067548195,
  "time_end": 1747067548267,
  "total_time": 72,
  "success": false,
  "cli_version": "3.75.0",
  "ruby_version": "",
  "node_version": "22.12.0",
  "is_employee": false,
  "uname": "windows amd64",
  "env_ci": false,
  "env_plugin_installed_any_custom": false,
  "env_plugin_installed_shopify": "[\"@shopify/cli\"]",
  "env_shell": "cmd.exe",
  "env_device_id": "******************************",
  "env_cloud": "localhost",
  "env_package_manager": "npm",
  "env_is_global": true,
  "env_auth_method": "device_auth",
  "cmd_app_warning_api_key_deprecation_displayed": false,
  "cmd_all_timing_network_ms": 0,
  "cmd_all_timing_prompts_ms": 0,
  "cmd_all_launcher": "unknown",
  "cmd_all_topic": "hydrogen",
  "cmd_all_plugin": "@shopify/cli-hydrogen",
  "cmd_all_verbose": true,
  "cmd_all_path_override": false,
  "cmd_all_timing_active_ms": 72,
  "cmd_all_exit": "unexpected_error",
  "user_id": "********-****-****-****-************",
  "request_ids": [],
  "args": "--codegen --host --verbose",
  "error_message": "Directory import 'D:\\******\\HYDROGEN\\******-v3\\node_modules\\vite' is not supported resolving ES modules imported from C:\\Users\\******\\AppData\\Roaming\\npm\\node_modules\\@shopify\\cli\\dist\\chunk-DV2H7WDY.js\nDid you mean to import \"file:///D:/******/HYDROGEN/******-v3/node_modules/vite/dist/node/index.js\"?",
  "env_plugin_installed_all": "[\"@shopify/cli\"]",
  "metadata": "{\"extraPublic\":{},\"extraSensitive\":{}}"
}
2025-05-12T16:32:28.872Z: Reporting unhandled error to Bugsnag: Directory import 'D:\******\HYDROGEN\******-v3\node_modules\vite' is not supported resolving ES modules imported from C:\Users\******\AppData\Roaming\npm\node_modules\@shopify\cli\dist\chunk-DV2H7WDY.js
Did you mean to import "file:///D:/******/HYDROGEN/******-v3/node_modules/vite/dist/node/index.js"?
2025-05-12T16:32:28.904Z: 
Running system process:
  · Command: npm prefix
  · Working directory: D:/******/HYDROGEN/******-v3

2025-05-12T16:32:29.030Z: Request to https://accounts.shopify.com/oauth/introspection completed in 291 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/"400675aea5ffc3198fdd598f50a77928"
 - server-timing: processing;dur=28, socket_queue;dur=1.19, edge;dur=1.039, util;dur=0.15, cfRequestDuration;dur=210.000038
 - x-request-id: ******-****-****-****-************

2025-05-12T16:32:29.031Z: The identity token is valid: true
2025-05-12T16:32:29.031Z: - Token validation -> It's invalid in identity: false
2025-05-12T16:32:29.032Z: Reading the content of file at .shopify/project.json...
2025-05-12T16:32:29.032Z: Writing some content to file at .shopify/project.json...
2025-05-12T16:32:29.033Z: Reading the content of file at .gitignore...
2025-05-12T16:32:29.034Z: Sending "Admin" GraphQL request:
  #graphql
  query PullVariables($id: ID!, $handle: String) {
    hydrogenStorefront(id: $id) {
      id
      environmentVariables(handle: $handle) {
        id
        isSecret
        readOnly
        key
        value
      }
    }
  }

With variables:
{
  "id": "******************************"
}

With request headers:
 - User-Agent: Shopify CLI; v=3.75.0
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: win32
 - Content-Type: application/json

to https://*******.myshopify.com/admin/api/unstable/graphql.json
2025-05-12T16:32:29.083Z: Obtaining the dependency manager in directory D:\******\HYDROGEN\******-v3...

It did not run anything, not sure if it is supposed to but it stops after

Obtaining the dependency manager

Hey @Drew thanks for sending those verbose logs over. That ERR_UNSUPPORTED_DIR_IMPORT error with Vite might be pointing to the the issue. I’ve had these kinds of module import issues pop up on me when using very newish Node versions.

One thing you could try would be to switch to the most up to date version of the Node LTS release (22.15.0), and then attempt the shopify hydrogen dev --host command again to see if that resolves the issue for you. If that doesn’t do the trick, just let me know, and I’m happy to do some more digging on my end internally here. :thumbsup: