Shopify Koa Auth importing a local version of @shopify/shopify-api?

scottyweeks
New Member
2 0 0

I'm trying to log in with oauth and I continually get a `UninitializedContextError.ShopifyError` with a stack trace like this:

Error: Context has not been properly initialized. Please call the .initialize() method to setup your app context object.
      at UninitializedContextError.ShopifyError [as constructor] (/Users/weeksie/Workspace/melty/melty-questions/node_modules/@shopify/koa-shopify-auth/node_modules/@shopify/shopify-api/dist/error.js:13:28)
      at new UninitializedContextError (/Users/weeksie/Workspace/melty/melty-questions/node_modules/@shopify/koa-shopify-auth/node_modules/@shopify/shopify-api/dist/error.js:63:42)
      at Object.throwIfUninitialized (/Users/weeksie/Workspace/melty/melty-questions/node_modules/@shopify/koa-shopify-auth/node_modules/@shopify/shopify-api/dist/context.js:62:19)

 

That would be all well and good and clear if shopify-koa-auth was using the same shopify api as I am, but it doesn't appear to be. The version it's using is nested under the package's `node_modules`, which is why the "global" Shopify.Context that I'm initializing in my sever config doesn't seem to matter. Is this a known issue? what's a good workaround?

0 Likes
scottyweeks
New Member
2 0 0

k, I think I found it. I was using `@shopify/shopify-api` version `1.2.0` and `@shopify/koa-shopify-auth` uses `1.1.0` so it was silently importing the wrong package. 

Might be worth documenting somewhere.

0 Likes
aksec
New Member
2 0 0

I had the same error while trying to deploy my app on Heroku.

The error looked like this:

 

 

 

Error: Context has not been properly initialized. Please call the .initialize() method to setup your app context object.
at UninitializedContextError.ShopifyError [as constructor] (/app/node_modules/@shopify/koa-shopify-auth/node_modules/@shopify/shopify-api/dist/error.js:13:28)

 

 

The problem was related to the one above: We updated some of our packages, but the Heroku build was still using some of the old versions that were cached.

So there was a mismatch between the version of shopify-api that we thought we were using and the version that was actually built against in Heroku.

To solve our issue:

  • Have the same version of @Shopify/shopify-api in our package.json as the one that is imported by @Shopify/koa-shopify-auth.
  • Prune the cache and the node_modules.
0 Likes