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

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_77 /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] [email removed]
┃ at new UninitializedContextError [email removed]
┃ at Object.throwIfUninitialized [email removed]
┃ at Object. [email removed]
┃ at step [email removed]
┃ at Object.next [email removed]
┃ at [email removed]
┃ at new Promise ()
┃ at Object.__awaiter [email removed]
┃ at Object.beginAuth [email removed]
┃ at [email removed]
┃ 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 ()
┃ 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”,
“url”: “git+https://github.com/Shopify/shopify-app-node.git
},
“author”: “Shopify Inc.”,
“license”: “MIT”,
“bugs”: {
“url”: “https://github.com/shopify/shopify-app-node/issues
},
“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”
]
}
}

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?

Ah fixed.

Run

npm uninstall @Shopify_77 /shopify-api

then run

npm install @Shopify_77 /koa-shopify-auth

and that will do it

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.