Keystone: Trouble running starter

Created on 26 Dec 2019  Â·  13Comments  Â·  Source: keystonejs/keystone

I attempted to follow these instructions to try out Keystone:

$ npm init keystone-app keystone-app
(choose postgres and nuxt app)
$ cd keystone-app
$ yarn start
...
**If this is the first time you've run Keystone, you can create your database with the following command:
createdb keystone_app
✖ Connecting to database
Error: database "keystone_app" does not exist
...

This was my first problem. It was easy enough to run createdb keystone_app but this wasn't in the instructions. You should probably mention it in the instructions.

I tried again and I ran into Vue errors

$ yarn dev
yarn run v1.19.1
$ cross-env NODE_ENV=development DISABLE_LOGGING=true keystone dev
ℹ Command: keystone dev
✔ Validated project entry file ./index.js
✔ Keystone server listening on port 3000
✔ Initialised Keystone instance
⠋ Connecting to databaseℹ Preparing project for development                                                                                                                                                               16:39:23
ℹ Initial build may take a while                                                                                                                                                                  16:39:23
⠹ Connecting to database✔ Builder initialized                                                                                                                                                                             16:39:23
⠴ Connecting to database✔ Nuxt files generated                                                                                                                                                                            16:39:24

✖ Client
  Compiled with some errors in 12.85s

✔ Server
  Compiled successfully in 10.00s


 ERROR  Failed to compile with 5 errors                                                                                                                                           friendly-errors 16:39:38

These dependencies were not found:                                                                                                                                                friendly-errors 16:39:38
                                                                                                                                                                                  friendly-errors 16:39:38
* core-js/modules/es6.regexp.to-string in ./dist/utils.js, ./dist/components/nuxt.js                                                                                              friendly-errors 16:39:38
* core-js/modules/es7.promise.finally in ./dist/client.js                                                                                                                         friendly-errors 16:39:38
* core-js/modules/es7.symbol.async-iterator in ./dist/client.js, ./dist/components/nuxt-link.client.js                                                                            friendly-errors 16:39:38
                                                                                                                                                                                  friendly-errors 16:39:38
To install them, you can run: npm install --save core-js/modules/es6.regexp.to-string core-js/modules/es7.promise.finally core-js/modules/es7.symbol.async-iterator               friendly-errors 16:39:38
ℹ Waiting for file changes                                                                                                                                                                        16:39:38
✔ Connected to database
✔ Keystone instance is ready at http://localhost:3000 🚀
🔗 Keystone Admin UI:    http://localhost:3000/admin
🔗 GraphQL Playground:   http://localhost:3000/admin/graphiql
🔗 GraphQL API:      http://localhost:3000/admin/api
[Vue warn]: Error in render: "TypeError: Cannot read property 'length' of null"

found in

---> <Src/pages/index.vue> at src/pages/index.vue
       <Nuxt>
         <Dist/layouts/default.vue> at dist/layouts/default.vue
           <Root>
[Vue warn]: Error in render: "TypeError: Cannot read property 'length' of null"

found in

---> <Src/pages/index.vue> at src/pages/index.vue
       <Nuxt>
         <Dist/layouts/default.vue> at dist/layouts/default.vue
           <Root>
[Vue warn]: Error in render: "TypeError: Cannot read property 'length' of null"

found in

---> <Src/pages/index.vue> at src/pages/index.vue
       <Nuxt>
         <Dist/layouts/default.vue> at dist/layouts/default.vue
           <Root>
[Vue warn]: Error in render: "TypeError: Cannot read property 'length' of null"

found in

---> <Src/pages/index.vue> at src/pages/index.vue
       <Nuxt>
         <Dist/layouts/default.vue> at dist/layouts/default.vue
           <Root>

Tried running the suggested npm install --save core-js/modules/es6.regexp.to-string core-js/modules/es7.promise.finally core-js/modules/es7.symbol.async-iterator but that failed.

Most helpful comment

I tried the vanilla javascript "todos" app and this time visited the admin UI. I see an error:

GraphQL error: select "t0".* from "public"."Todo" as "t0" where true order by "name" ASC limit $1 - relation "public.Todo" does not exist GraphQL error: select count(*) from "public"."Todo" as "t0" where true - relation "public.Todo" does not exist

All 13 comments

I tried the vanilla javascript "todos" app and this time visited the admin UI. I see an error:

GraphQL error: select "t0".* from "public"."Todo" as "t0" where true order by "name" ASC limit $1 - relation "public.Todo" does not exist GraphQL error: select count(*) from "public"."Todo" as "t0" where true - relation "public.Todo" does not exist

I ran into the same issue -- when using Postgres, Keystone is not creating tables or rows. That's the cause of the GraphQL error in the admin, and is also the cause of the the "Cannot read property 'length' of null" errors in the Vue template. This all works fine with MongoDB.

The missing dependencies errors seems to be unrelated and can be fixed using this snippet: https://github.com/keystonejs/keystone/issues/1843#issuecomment-562912835

Even after manually creating the necessary tables and rows in Postgres, I have issues actually using the sample Todo app -- items get created but with null IDs, etc. I'm probably not setting up the tables and rows correctly because I'm not supposed to have to.

Same problem with Postgres here. The yarn dev command reports it has "Connected to database" but it fails to create any tables in the database. As a result, the application does not work at all.

same for me, tried all the installations with Nuxt, Knex (Postgres), keystone is not running, same messages as above (on windows 10)

I'm having the exact same issue with tables not being created perhaps? The error on the dashboard is

GraphQL error: select count(*) from "public"."Todo" as "t0" where true - relation "public.Todo" does not exist

Is this just going to be an issue with the sample app, or Keystone isn't ready for Postgres in general?

If I had to guess I'd say Postgres and/or Knex changed something and Keystone seems to assume you're using Mongo and Postgres support is an afterthought. I'd love to use Mongo too but the host I'm using for this project doesn't support it and paying for hosting isn't an option. I may end up going with a static site but half of the point of this was to experiment with Nuxt and SSR.

It looks like there are conflicting peer dependencies for graphql. ~I wouldn't be surprised if the missing functionality is related in some way.~ Edit: These conflicted peer dependencies also exist in a Nuxt + Mongoose installation (which functions correctly), so they may not be relevant to the solution.

Out of the box:

[email protected] requires a peer of graphql@^0.6.0 || ^0.7.0 || ^0.8.0-b || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0
[email protected] requires a peer of graphql@^0.10.0 || ^0.11.0 || ^0.12.0
[email protected] requires a peer of graphql@^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0
[email protected] requires a peer of graphql@^0.11.0 || ^0.12.0 || ^0.13.0
[email protected] requires a peer of graphql@^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0
[email protected] requires a peer of graphql@^0.11.0 || ^0.12.0 || ^0.13.0

_Installs graphql@^0.12.0_

@apollo/[email protected] requires a peer of graphql@^14.3.1
@apollo/[email protected] requires a peer of graphql@^14.3.1
[email protected] requires a peer of graphql@^14.2.1
[email protected] requires a peer of graphql@^0.13.0 || ^14.0.0
[email protected] requires a peer of [email protected] - 14

So there's currently a need for version 0.12.0 and 14 simultaneously.


All other peer dependencies that are missing out of the box seem to be resolvable, save for react-codemirror, which needs to have its dependencies updated to allow react and react-dom above 16, but looks to be abandoned.

createdb keystone_app

Where is this command supposed to be run? I'm trying to connect to Postgres.
And I'm having the same problem: Keystone doesn't create the tables in the Postgres database.

I also created a project with npm init keystone-app server and chose Starter and postgres. Starter includes some starting users stuff.

I ran the postgres command createdb my_super_cool_project_name and then spun it up with yarn dev. I didn't see anything about what the admin would be, and couldn't login in at /admin.

So as I started debugging, initial-data.js expects count to be === to 0. It was null. Which I didn't realize was because the following query doesn't work.

query {
      _allUsersMeta {
        count
      }
    }

When looking at what's in the postgres database, it doesn't seem to contain any tables. Looking for related issues on postgres support.

Same issue for me.

I'm starting Postgres as follows:

docker run --name keystone-pg \
  -e POSTGRES_PASSWORD=password \
   -d \
   -p 5432:5432 postgres

And then start Dev mode:

DATABASE_URL=postgres://postgres:password@localhost:5432/keystone && yarn dev

Keystone start without issue but when loading the dashboard the following error is displayed:

GraphQL error: select count(*) from "public"."Todo" as "t0" where true - relation "public.Todo" does not exist

I have found a workaround to the problem by forcing a dropDatabase on startup. I have uploaded my working example to GitHub if that helps anyone: https://github.com/mxro/keystone-playground#keystonejs-todo-getting-started

I have just started looking at KeystoneJS today so I am sure there is a more elegant solution to get it working.

Hi @justinmoon, sorry this took so long to get to. We have just updated the getting started guide and the create-keystone-app package to better support the getting started experience for postgres users. I have confirmed that the combination of Nuxt on Postgres works out of the box now, so I'm going to close this issue.

If any of the other issues that have been raised in the comments are still a problem then please open a fresh github issue so we can individually track them.

New user, followed latest getting started with postgres. Tables are still not being created by adding lists. Have to run

npm run create-tables

which will complain unless db dropped.
Using "@keystonejs/adapter-knex": "^10.0.1"

In what version should it be resolved? Is #2414 merged?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ra-external picture ra-external  Â·  10Comments

jesstelford picture jesstelford  Â·  19Comments

cowjen01 picture cowjen01  Â·  13Comments

bholloway picture bholloway  Â·  18Comments

jossmac picture jossmac  Â·  10Comments