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

scottyweeks
New Member
2 0 1

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?

Replies 7 (7)
scottyweeks
New Member
2 0 1

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.

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.
PublicApps
Shopify Partner
142 5 34
npm uninstall @Shopify/shopify-api
npm uninstall @Shopify/koa-shopify-auth
npm install --save @Shopify/koa-shopify-auth

Public Apps | Theme customization & App development
 - Was my reply useful? Like it to let me know!
 - Did I answer your question? Please mark as Accepted Solution.
 - Need more help? Contact us.

antondrob
Tourist
7 1 2
npm uninstall @Shopify/shopify-api
npm uninstall @Shopify/koa-shopify-auth
npm install --save @Shopify/koa-shopify-auth
ConspireAgency
Shopify Expert
32 3 16

@Shopify/koa-shopify-auth includes @Shopify/shopify-api as a dependency, so as long as you use the former you do not need to include @Shopify/shopify-api as a dependency in your package.json.

 

Had this issue happen to me as well and it's due to the two conflicting.

Conspire Agency //
Los Angeles, California //
https://conspireagency.com
View my showreel: https://www.youtube.com/watch?v=E9upo48FQUg
Zeeshan01
Tourist
3 0 0

incase you are available i need help in connection with shopify admin api

RohitSharma12
Shopify Partner
25 2 2

Thank you, that worked perfectly for me. All letters, however, should be written in lowercase.

 

npm uninstall shopify/shopify-api

npm uninstall shopify/koa-shopify-auth

npm install --save shopify/koa-shopify-auth

 

Use @ symbol before every commend (@shopify/shopify-api).