keystone: Building static pages fails with prerendering errors - Cannot read properties of null (reading 'useContext')

Upgrade to @keystone-6/ui 2.0.0 (from 1.1.1), run keystone build

Expected: The Admin UI bundle builds successfully. Actual: Building static pages fails with the errors shown in the screenshot below.

image

Node version v16.15.1.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 1
  • Comments: 19 (8 by maintainers)

Most upvoted comments

@kirandash the suggestion also works for me.

Fresh starting a Keystone app with yarn create keystone-app will install the required dependencies and yarn dev will start the app. However visiting any page will throw an exception: Cannot read properties of null (reading 'useContext')

I got it to work for node v20


{
  "name": "keystone-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "keystone dev",
    "start": "keystone start",
    "build": "keystone build",
    "postinstall": "keystone build --no-ui --frozen"
  },
  "dependencies": {
    "@keystone-6/auth": "^7.0.0",
    "@keystone-6/core": "^5.0.0",
    "@keystone-6/fields-document": "^7.0.0",
    "typescript": "^4.9.5"
  },
  "resolutions": {
    "**/@azure/msal-node": "2.7.0"
  }
}

@kirandash try this solution #8553 . It works to me

Thanks @u-ishii

Here are the dependencies from package.json.

  "dependencies": {
    "@keystone-6/core": "^2.0.0",
    "typescript": "^4.5.4"
  },

According to the docs, that should be all that’s required to run Keystone - is that correct? In addition, this only started happening with Keystone 2.0.0, and with Node version < 18.