Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot initialize Shopify API Library. Missing values for: hostName in Reactjs

I am working with "shopify" and "nodejs",Right now i am trying to integrate "shopify module" in nodejs,But i am getting following error

"ShopifyError: Cannot initialize Shopify API Library. Missing values for: hostName"

Here is my config.js code (node_modules/@shopify/shopify-api/lib/config.js",Is this hostname right or where can i get hostname ? why i am getting error "missing hostname" ?

var config = {
        apiKey: '',
        apiSecretKey: '',
        scopes: new scopes_1.AuthScopes([]),
        hostName: 'https://partners.shopify.com/xxxxx/stores',
        hostScheme: 'https',
        apiVersion: types_1.LATEST_API_VERSION,
        isEmbeddedApp: true,
        isPrivateApp: false,
        logger: {
            log: defaultLogFunction,
            level: types_1.LogSeverity.Info,
            httpRequests: false,
            timestamps: false,
        },
    };

1 Answers

I had a this issue when attempting npm run serve (the default command for production environment with their Docker configuration). In my case, the .env was missing a HOST field.

Shopify Docs say HOST is required. This was tricky to diagnose because:

  1. Shopify doesn't create a HOST field in the env by default
  2. Shopify doesn't parse/validate the ENV up front
  3. Shopify's error message directs developer to a node_modules file
  4. Shopify renames HOST to hostName in their code
like image 121
bristweb Avatar answered Sep 14 '25 21:09

bristweb