Solved

Shopify-api Please call the .initialize() method to setup your app context object.

Radixsecur1ty
Shopify Partner
18 4 7

Hello Guys,

 

I have created a brand new node app through shopify cli.

 

The app starts good, works good.

 

I have installed this package and than the app is completly broken: npm install --save @Shopify/shopify-api

 

I have found here: https://shopify.dev/api/admin-graphql#top

 

The error what i got is the next one:

Error: Context has not been properly initialized. Please call the .initialize() method to setup your app context object.
┃ at UninitializedContextError.ShopifyError [as constructor] (D:\Projects\Shoppify\test1\node_modules\@shopify\koa-shopify-auth\node_modules\@shopify\shopify-api\dist\error.js:13:28)
┃ at new UninitializedContextError (D:\Projects\Shoppify\test1\node_modules\@shopify\koa-shopify-auth\node_modules\@shopify\shopify-api\dist\error.js:63:42)
┃ at Object.throwIfUninitialized (D:\Projects\Shoppify\test1\node_modules\@shopify\koa-shopify-auth\node_modules\@shopify\shopify-api\dist\context.js:66:19)
┃ at Object.<anonymous> (D:\Projects\Shoppify\test1\node_modules\@shopify\koa-shopify-auth\node_modules\@shopify\shopify-api\dist\auth\oauth\oauth.js:38:43)
┃ at step (D:\Projects\Shoppify\test1\node_modules\@shopify\koa-shopify-auth\node_modules\@shopify\shopify-api\node_modules\tslib\tslib.js:143:27)
┃ at Object.next (D:\Projects\Shoppify\test1\node_modules\@shopify\koa-shopify-auth\node_modules\@shopify\shopify-api\node_modules\tslib\tslib.js:124:57)
┃ at D:\Projects\Shoppify\test1\node_modules\@shopify\koa-shopify-auth\node_modules\@shopify\shopify-api\node_modules\tslib\tslib.js:117:75
┃ at new Promise (<anonymous>)
┃ at Object.__awaiter (D:\Projects\Shoppify\test1\node_modules\@shopify\koa-shopify-auth\node_modules\@shopify\shopify-api\node_modules\tslib\tslib.js:113:16)
┃ at Object.beginAuth (D:\Projects\Shoppify\test1\node_modules\@shopify\koa-shopify-auth\node_modules\@shopify\shopify-api\dist\auth\oauth\oauth.js:33:24)
┃ at D:\Projects\Shoppify\test1\node_modules\@shopify\koa-shopify-auth\dist\src\auth\index.js:61:73
┃ at step (D:\Projects\Shoppify\test1\node_modules\tslib\tslib.js:133:27)
┃ at Object.next (D:\Projects\Shoppify\test1\node_modules\tslib\tslib.js:114:57)
┃ at D:\Projects\Shoppify\test1\node_modules\tslib\tslib.js:107:75
┃ at new Promise (<anonymous>)
┃ at Object.__awaiter (D:\Projects\Shoppify\test1\node_modules\tslib\tslib.js:103:16)

 

I have attached my package-json files too.

What could go wrong?

Thank you for your help Guys in advance.

 

 

 

{
  "name": "shopify-app-node",
  "version": "1.0.0",
  "description": "Shopify's node app for CLI tool",
  "scripts": {
    "test": "jest",
    "dev": "cross-env NODE_ENV=development nodemon ./server/index.js --watch ./server/index.js",
    "build": "NEXT_TELEMETRY_DISABLED=1 next build",
    "start": "cross-env NODE_ENV=production node ./server/index.js"
  },
  "repository": {
    "type": "git",
  },
  "author": "Shopify Inc.",
  "license": "MIT",
  "bugs": {
  },
  "dependencies": {
    "@babel/core": "7.12.10",
    "@babel/polyfill": "^7.6.0",
    "@babel/preset-env": "^7.12.11",
    "@babel/register": "^7.12.10",
    "@shopify/app-bridge": "^2.0.5",
    "@shopify/app-bridge-react": "^2.0.2",
    "@shopify/app-bridge-utils": "^2.0.2",
    "@shopify/koa-shopify-auth": "^4.1.2",
    "@shopify/polaris": "^6.2.0",
    "@shopify/shopify-api": "^2.0.0",
    "apollo-boost": "^0.4.9",
    "cross-env": "^7.0.3",
    "dotenv": "^8.2.0",
    "graphql": "^14.5.8",
    "isomorphic-fetch": "^3.0.0",
    "koa": "^2.13.1",
    "koa-router": "^10.0.0",
    "koa-session": "^6.1.0",
    "next": "^10.0.4",
    "next-env": "^1.1.0",
    "node-fetch": "^2.6.1",
    "react": "^16.10.1",
    "react-apollo": "^3.1.3",
    "react-dom": "^16.10.1",
    "webpack": "^4.44.1"
  },
  "devDependencies": {
    "@babel/plugin-transform-runtime": "^7.12.10",
    "@babel/preset-stage-3": "^7.0.0",
    "babel-jest": "26.6.3",
    "babel-register": "^6.26.0",
    "enzyme": "3.11.0",
    "enzyme-adapter-react-16": "1.15.5",
    "husky": "^4.3.6",
    "jest": "26.6.3",
    "lint-staged": "^10.5.3",
    "nodemon": "^2.0.0",
    "prettier": "2.2.1",
    "react-addons-test-utils": "15.6.2",
    "react-test-renderer": "16.14.0"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.{js,css,json,md}": [
      "prettier --write"
    ]
  }
}

 

Accepted Solution (1)

Radixsecur1ty
Shopify Partner
18 4 7

This is an accepted solution.

The solution was something completly different.
It package was not correctly initialized.
Through the latest shopify CLI when we create a new node app this package has been set correctly.

View solution in original post

Replies 3 (3)

GetJuicy
Shopify Partner
11 1 5

Did you manage to find a solution?

 

This thread mentions uninstalling shopify api module but tried it and it doesn't work either. I think may it needs to be a specific version of the module?

GetJuicy
https://getjuicy.co.uk
Contact us for further Shopify support and help
-If this solution is worked, then please Like this and Mark this as accepted solution!

GetJuicy
Shopify Partner
11 1 5

Ah fixed.

 

Run

npm uninstall @Shopify/shopify-api

then run

npm install @Shopify/koa-shopify-auth

 

and that will do it

GetJuicy
https://getjuicy.co.uk
Contact us for further Shopify support and help
-If this solution is worked, then please Like this and Mark this as accepted solution!

Radixsecur1ty
Shopify Partner
18 4 7

This is an accepted solution.

The solution was something completly different.
It package was not correctly initialized.
Through the latest shopify CLI when we create a new node app this package has been set correctly.