gatsby-plugin-mdx gives "TypeError: createTypes is not a function"

Created on 19 Sep 2019  Β·  16Comments  Β·  Source: gatsbyjs/gatsby

Description

After installing the gatsby-plugin-mdx following instructions, it throws errors when starting.

Expected result

Shouldn't give errors and able to render .mdx files.

Actual result

Screen Shot 2019-09-19 at 12 29 19 AM

stale? needs reproduction MDX bug

Most helpful comment

@joe-bell @thebarty @sounak98 @Batistleman
dunno if it's still relevant for you guys but @ChristopherBiscardi was right. Gatsby version was so out of date.

If you update gatsby everything should be good. Check your lock files.

All 16 comments

Hi!

Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it.

If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look.

Thanks for using Gatsby! πŸ’œ

@bhavin-prajapati Did you manage to solve this? I'm also getting this error.

Also getting this! It's a little frustrating considering trying to migrate from gatsby-mdx without any guidance/documentation on the transition

success open and validate gatsby-configs β€” 0.019 s
success load plugins β€” 0.293 s
success onPreInit β€” 3.060 s
success delete html and css files from previous builds β€” 0.005 s
success initialize cache β€” 0.005 s
success copy gatsby files β€” 0.161 s
success onPreBootstrap β€” 0.008 s
error Plugin gatsby-plugin-mdx returned an error
[1] docs: 
[1] docs:   TypeError: createTypes is not a function
[1] docs:   
[1] docs:   - source-nodes.js:63 Object.module.exports [as sourceNodes]
[1] docs:     [root-project]/[gatsby-plugin-mdx]/gatsby/source-nodes.js:63:3
[1] docs:   
[1] docs:   - api-runner-node.js:146 runAPI
[1] docs:     [docs]/[gatsby]/dist/utils/api-runner-node.js:146:37
[1] docs:   
[1] docs:   - api-runner-node.js:254 resolve
[1] docs:     [docs]/[gatsby]/dist/utils/api-runner-node.js:254:19
[1] docs:   
[1] docs:   - debuggability.js:313 Promise._execute
[1] docs:     [root-project]/[bluebird]/js/release/debuggability.js:313:9
[1] docs:   
[1] docs:   - promise.js:488 Promise._resolveFromExecutor
[1] docs:     [root-project]/[bluebird]/js/release/promise.js:488:18
[1] docs:   
[1] docs:   - promise.js:79 new Promise
[1] docs:     [root-project]/[bluebird]/js/release/promise.js:79:10
[1] docs:   
[1] docs:   - api-runner-node.js:253 Promise.mapSeries.plugin
[1] docs:     [docs]/[gatsby]/dist/utils/api-runner-node.js:253:16
[1] docs:   
[1] docs:   - util.js:16 tryCatcher
[1] docs:     [root-project]/[bluebird]/js/release/util.js:16:23
[1] docs:   
[1] docs:   - reduce.js:155 Object.gotValue
[1] docs:     [root-project]/[bluebird]/js/release/reduce.js:155:18
[1] docs:   
[1] docs:   - reduce.js:144 Object.gotAccum
[1] docs:     [root-project]/[bluebird]/js/release/reduce.js:144:25
[1] docs:   
[1] docs:   - util.js:16 Object.tryCatcher
[1] docs:     [root-project]/[bluebird]/js/release/util.js:16:23
[1] docs:   
[1] docs:   - promise.js:517 Promise._settlePromiseFromHandler
[1] docs:     [root-project]/[bluebird]/js/release/promise.js:517:31
[1] docs:   
[1] docs:   - promise.js:574 Promise._settlePromise
[1] docs:     [root-project]/[bluebird]/js/release/promise.js:574:18
[1] docs:   
[1] docs:   - promise.js:619 Promise._settlePromise0
[1] docs:     [root-project]/[bluebird]/js/release/promise.js:619:10
[1] docs:   
[1] docs:   - promise.js:699 Promise._settlePromises
[1] docs:     [root-project]/[bluebird]/js/release/promise.js:699:18
[1] docs:   
[1] docs:   - async.js:138 _drainQueueStep
[1] docs:     [root-project]/[bluebird]/js/release/async.js:138:12
[1] docs:   
[1] docs: 
success source and transform nodes β€” 5.545 s
success building schema β€” 0.426 s
success createPages β€” 0.063 s
success createPagesStatefully β€” 0.053 s
success onPreExtractQueries β€” 0.010 s
success update schema β€” 0.138 s
error GraphQL Error There was an error while compiling your site's GraphQL queries.
[1] docs:   Error: RelayParser: Encountered 1 error(s):
[1] docs: - Unknown field 'body' on type 'Mdx'. Source: document `REDACTED1546307396` file: `GraphQL request`
[1] docs:   
[1] docs:   GraphQL request (5:7)
[1] docs:   4:       id
[1] docs:   5:       body
[1] docs:            ^
[1] docs:   6:       frontmatter {
[1] docs:   
[1] docs:     
success extract queries from components β€” 0.141 s
success run graphql queries β€” 0.046 s β€” 31/31 699.04 queries/second
success write out page data β€” 0.004 s
success write out redirect data β€” 0.001 s
[1] docs: done generating icons for manifest
success onPostBootstrap β€” 0.159 s

info bootstrap finished - 15.195 s

and here are the dependencies used:

"dependencies": {
    "@emotion/core": "10.0.10",
    "@emotion/styled": "10.0.9",
    "@mdx-js/mdx": "1.5.0",
    "@mdx-js/react": "1.5.0",
    "gatsby": "2.15.28",
    "gatsby-cli": "2.7.53",
    "gatsby-image": "2.2.239",
    "gatsby-plugin-emotion": "4.0.4",
    "gatsby-plugin-manifest": "2.2.20",
    "gatsby-plugin-mdx": "1.0.46",
    "gatsby-plugin-offline": "3.0.11",
    "gatsby-plugin-react-helmet": "3.1.10",
    "gatsby-plugin-sharp": "2.2.27",
    "gatsby-plugin-typescript": "2.1.11",
    "gatsby-remark-autolink-headers": "2.1.13",
    "gatsby-source-filesystem": "2.1.28",
    "gatsby-transformer-json": "2.2.11",
    "gatsby-transformer-sharp": "2.2.19",
    "mdx-utils": "0.1.0",
    "polished": "3.4.1",
    "prism-react-renderer": "0.1.5",
    "react": "16.8.1",
    "react-dom": "16.8.1",
    "react-helmet": "5.2.0",
    "react-live": "1.12.0"
  }

@bhavin-prajapati Batistleman any luck?

@joe-bell can you pick up on what @LekoArts said and possibly create a reproduction so that it can be looked at in more detail and with that possibly offer a solution for you and the other people involved?

Cheers, I'll see if I can get some time to convert my client's project into a generic repro

in gatsby/source-node.js inside of the plugin folder there is this code:

module.exports = (
  { store, pathPrefix, getNode, getNodes, cache, reporter, actions, schema },
  pluginOptions
) => {
  let mdxHTMLLoader
  const { createTypes } = actions

actions does not have a createType method and schema is undefined

Looks like you're right @AlbertoMontalesi:
https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-mdx/gatsby/source-nodes.js#L59

Do you have any suggestions for a workaround here or does the schema need defining?

Hiya!

This issue has gone quiet. Spooky quiet. πŸ‘»

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! πŸ’ͺπŸ’œ

Please keep open, not stale

@ChristopherBiscardi I know you're probably the expert here when it comes to MDX, could you possibly advise on this please? I'd be happy to help if I can but I'm not too experienced when it comes to creating types in the schema.

As mentioned in my first comment we need a reproduction of the problem to be able to help.

@joe-bell The problems indicated here sound like the gatsby version is so out of date that it doesn't have the schema customization APIs available to it. Is the lockfile pinning gatsby to an older version maybe?

Otherwise it's hard to debug this, as @LekoArts said, without someone providing a potential repro as I've never seen this issue before.

Hiya!

This issue has gone quiet. Spooky quiet. πŸ‘»

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! πŸ’ͺπŸ’œ

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.
Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! πŸ’ͺπŸ’œ

Seeing the exact same error. Anyone solved this?

Anyone fixed this issue?

@joe-bell @thebarty @sounak98 @Batistleman
dunno if it's still relevant for you guys but @ChristopherBiscardi was right. Gatsby version was so out of date.

If you update gatsby everything should be good. Check your lock files.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

totsteps picture totsteps  Β·  3Comments

hobochild picture hobochild  Β·  3Comments

ferMartz picture ferMartz  Β·  3Comments

jimfilippou picture jimfilippou  Β·  3Comments

magicly picture magicly  Β·  3Comments