question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

keystone.getResolvers is not a function

See original GitHub issue

NOTE: I notice there have been some changes in the last day to the Keystone repo, so perhaps when I reinstalled my node_modules it grabbed the latest version and that is causing the problem?

I’m working on a KeystoneJS project. I added hooks to one of my lists and the project worked fine. When I was finished with my work I pushed my work to GitHub and made a pull request for my team. However GitHub complained about a security error (in yarn.lock), so I deleted yarn.lock, reinstalled node_modules(yarn). When I ran the project again locally, however, I received the following error:

✔ Validated project entry file ./tsout/index.js
✔ Keystone server listening on port 4545
✔ Initialised Keystone instance
✖ Connecting to database
TypeError: keystone.getResolvers is not a function
    at createApolloServer (/Users/r/Documents/projects/yaa-keystone/node_modules/@keystonejs/app-graphql/lib/apolloServer.js:148:25)
    at GraphQLApp.prepareMiddleware (/Users/r/Documents/projects/yaa-keystone/node_modules/@keystonejs/app-graphql/index.js:23:20)
    at /Users/r/Documents/projects/yaa-keystone/node_modules/@keystonejs/keystone/lib/Keystone/index.js:752:17
    at Array.map (<anonymous>)
    at Keystone.prepare (/Users/r/Documents/projects/yaa-keystone/node_modules/@keystonejs/keystone/lib/Keystone/index.js:751:12)
    at executeDefaultServer (/Users/r/Documents/projects/yaa-keystone/node_modules/@keystonejs/keystone/bin/utils.js:112:42)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

It’s throwing the error deep inside the keystone package in node_modules. I deleted and reinstalled node_modules, I reverted my project to a commit from yesterday that worked fine, but I keep getting the same error.

I went back to the already-working ’develop` branch and the same issue. It must be something inside node_modules?

Any help appreciated, as I’m dead in the water now.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
jesstelfordcommented, Mar 24, 2020

You’re correct; this was changed in a release that went out about 10hrs ago.

There’s a chance that the version of @keystonejs/keystone your project depends on is different to the version which @keystonejs/app-graphql depends on. If that’s the case, then this error will occur.

You could verify this with yarn:

yarn why @keystonejs/keystone

Ideally, that would show only one version, but I suspect it will show you two versions.

By removing your yarn.lock, yarn has been instructed to fetch the latest versions of packages, and led to this issue. It’s generally a good idea to avoid removing yarn.lock in its entirety for this and similar reasons. (Personally, I do still delete it sometimes as it’s the only way to get certain things to happen).

Two possible solutions to your current problem:

  1. Revert the changes in yarn.lock, remove your node_modules folder, and run yarn again.

    • If this continues to throw errors, go through your keystone dependencies in package.json, and remove any semver range specifiers, then re-run yarn For example, make this change:
    -  "@keystonejs/keystone": "^1.0.0",
    +  "@keystonejs/keystone": "1.0.0",
    

    This should lock down the versions

  2. Preferred. Use ~yarn outdated --latest~ yarn upgrade-interactive --latest to update to the latest versions of all @keystonejs/* packages.

1reaction
jesstelfordcommented, Mar 25, 2020

Really sorry about the headaches this has caused you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

"keystone.getResolvers is not a function" after deleting yarn ...
This turned out to be an error with new package updates to KeystoneJS conflicting with my code. When I removed yarn.lock and ran...
Read more >
Resolvers – GraphQL Tools
Resolvers are per field functions that are given a parent object, arguments, and the execution context, and are responsible for returning a ...
Read more >
Headless CMS & GraphQL API with KeystoneJS - YouTube
Build a GraphQL API using KeystoneJSCode:https://github.com/bradtraversy/ keystone -blogCode:https://github.com/bradtraversy/next-.
Read more >
Unity - Scripting API:
This function is called when the Playable play state is changed to Playables.PlayState.Delayed. PlayableBehaviour.OnBehaviourPause. This function is called ...
Read more >
How to solve the "is not a function" error in JavaScript
js we use require() to load external modules and files. This can cause, in some cases, an error like this: TypeError: require(...) is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found