Closed colbyfayock closed 6 years ago
I'm not sure what's causing that... as a debugging step I'd try moving the code from your various ./gatsby-node/
requires back into the main gatsby-node.js
. If that works, then move things out bit by bit until you can reproduce the error.
good call. it looks like the webpack config import was the offender, perhaps there's an issue with the export. will just carry on with that particular one in the gatsby-node
file. thanks for the help
@colbyfayock Have you ever found out? Facing the same error message. Thanks!
@gregoryforel could you share a repo or reproduction of the issue? It's likely that you're exporting an API (i.e. in a file) that isn't an actual Gatsby API!
@gregoryforel it had to do with how I was running the exports relating to the custom webpack config, but i didn't ever figure out the exact issue as we didn't even need the custom config anymore. if you're able to provide some code to look at like DSchau mentioned, we might be able to help debug
@DSchau Thanks! Here you go: https://github.com/gregoryforel/gatsby-typescript-graphcms
@colbyfayock @DSchau I'm really new to Gatsby and GraphCMS. So far, just trying to setup a starterkit to be able to work in Typescript. I'm almost there, it was working before I tried to what clarkdave described in this thread, very last post: https://github.com/gatsbyjs/gatsby/issues/1457
@gregoryforel so we're in agreement that the repo (as authored) works just fine, right? I wasn't able to reproduce any errors!
It seems like you run into errors when you start requiring ts-node?
@DSchau Indeed. That's what I get:
yarn run v1.7.0
$ gatsby develop
success open and validate gatsby-config β 0.006 s
success load plugins β 0.173 s
success onPreInit β 0.323 s
success delete html and css files from previous builds β 0.012 s
success initialize cache β 0.021 s
success copy gatsby files β 0.076 s
success onPreBootstrap β 0.012 s
success source and transform nodes β 0.429 s
success building schema β 0.115 s
error gatsby-node.js returned an error
TypeError: gatsbyNode[api] is not a function
- api-runner-node.js:136 runAPI
[gatsby-source-graphql]/[gatsby]/src/utils/api-runner-node.js:136:22
- api-runner-node.js:242 runAPI
[gatsby-source-graphql]/[gatsby]/src/utils/api-runner-node.js:242:9
- util.js:16 tryCatcher
[gatsby-source-graphql]/[bluebird]/js/release/util.js:16:23
- reduce.js:155 Object.gotValue
[gatsby-source-graphql]/[bluebird]/js/release/reduce.js:155:18
- reduce.js:144 Object.gotAccum
[gatsby-source-graphql]/[bluebird]/js/release/reduce.js:144:25
- util.js:16 Object.tryCatcher
[gatsby-source-graphql]/[bluebird]/js/release/util.js:16:23
- promise.js:512 Promise._settlePromiseFromHandler
[gatsby-source-graphql]/[bluebird]/js/release/promise.js:512:31
- promise.js:569 Promise._settlePromise
[gatsby-source-graphql]/[bluebird]/js/release/promise.js:569:18
- promise.js:614 Promise._settlePromise0
[gatsby-source-graphql]/[bluebird]/js/release/promise.js:614:10
- promise.js:694 Promise._settlePromises
[gatsby-source-graphql]/[bluebird]/js/release/promise.js:694:18
- async.js:138 _drainQueueStep
[gatsby-source-graphql]/[bluebird]/js/release/async.js:138:12
- async.js:131 _drainQueue
[gatsby-source-graphql]/[bluebird]/js/release/async.js:131:9
- async.js:147 Async._drainQueues
[gatsby-source-graphql]/[bluebird]/js/release/async.js:147:5
- async.js:17 Immediate.Async.drainQueues
[gatsby-source-graphql]/[bluebird]/js/release/async.js:17:14
error Cannot read property 'filter' of undefined
TypeError: Cannot read property 'filter' of undefined
- api-runner-node.js:266 filter
[gatsby-source-graphql]/[gatsby]/src/utils/api-runner-node.js:266:42
- util.js:16 tryCatcher
[gatsby-source-graphql]/[bluebird]/js/release/util.js:16:23
- promise.js:512 Promise._settlePromiseFromHandler
[gatsby-source-graphql]/[bluebird]/js/release/promise.js:512:31
- promise.js:569 Promise._settlePromise
[gatsby-source-graphql]/[bluebird]/js/release/promise.js:569:18
- promise.js:614 Promise._settlePromise0
[gatsby-source-graphql]/[bluebird]/js/release/promise.js:614:10
- promise.js:694 Promise._settlePromises
[gatsby-source-graphql]/[bluebird]/js/release/promise.js:694:18
- async.js:138 _drainQueueStep
[gatsby-source-graphql]/[bluebird]/js/release/async.js:138:12
- async.js:131 _drainQueue
[gatsby-source-graphql]/[bluebird]/js/release/async.js:131:9
- async.js:147 Async._drainQueues
[gatsby-source-graphql]/[bluebird]/js/release/async.js:147:5
- async.js:17 Immediate.Async.drainQueues
[gatsby-source-graphql]/[bluebird]/js/release/async.js:17:14
error UNHANDLED REJECTION
TypeError: Cannot read property 'filter' of undefined
- api-runner-node.js:266 filter
[gatsby-source-graphql]/[gatsby]/src/utils/api-runner-node.js:266:42
- util.js:16 tryCatcher
[gatsby-source-graphql]/[bluebird]/js/release/util.js:16:23
- promise.js:512 Promise._settlePromiseFromHandler
[gatsby-source-graphql]/[bluebird]/js/release/promise.js:512:31
- promise.js:569 Promise._settlePromise
[gatsby-source-graphql]/[bluebird]/js/release/promise.js:569:18
- promise.js:614 Promise._settlePromise0
[gatsby-source-graphql]/[bluebird]/js/release/promise.js:614:10
- promise.js:694 Promise._settlePromises
[gatsby-source-graphql]/[bluebird]/js/release/promise.js:694:18
- async.js:138 _drainQueueStep
[gatsby-source-graphql]/[bluebird]/js/release/async.js:138:12
- async.js:131 _drainQueue
[gatsby-source-graphql]/[bluebird]/js/release/async.js:131:9
- async.js:147 Async._drainQueues
[gatsby-source-graphql]/[bluebird]/js/release/async.js:147:5
- async.js:17 Immediate.Async.drainQueues
[gatsby-source-graphql]/[bluebird]/js/release/async.js:17:14
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@gregoryforel would you mind "breaking it" in a branch or something of the repo?
What do you mean exactly?
@gregoryforel it's hard for me to reproduce exactly what you have (that's broken) if I can't see how it's broken! The repo in its current state works just fine!
@DSchau I'm so stupid... I forgot to commit my changes, I pushed the working repo. Sorry for that. Check the bugfix branch please, just uploaded it.
@gregoryforel definitely not! Happens to all of us! Checking it out now.
@gregoryforel the issue is that gatsby-node.js
(CommonJS) is requiring (via ts-node) a Typescript file, which is an and of itself, fine.
However, the issue is that you're presuming the "default" (i.e. module.exports) with this line in gatsby-node.js
exports.createPages = require('./createPages')
when createPages.ts
actually contains
export const createPages = () => {};
so you can fix that in a few ways. Easiest is just changing the require statement in gatsby-node.js
exports.createPages = require('./createPages').createPages
@DSchau Thank you so much, I would not have caught that. I'm peeling the onion, now seeing other errors, but I should manage. Cheers
@gregoryforel yup yup, I saw a few too :) One of them is the result of the graphql
function call is an object containing a data
property which contains the result of the GraphQL query. So you just need one more data
subproperty, and it should be mostly good after that!
And you're very welcome. Thanks for using Gatsby π
@DSchau I should hire you ;) Just solved this error too. I should not have tried to do everything at the same time: new to Gatsby, GraphQL, GraphCMS... If the user support keeps being like this, you guys have a great future
Description
Getting a
TypeError: gatsbyNode[api] is not a function
error when trying to start up after migration to Gatsby v2.To get started, we ran through the documentation and whatever debugging we could figure out via the issues: https://next.gatsbyjs.org/docs/migrating-from-v1-to-v2/
Please let me know if I missed anything below. Thanks in advance
Steps to reproduce
gatsby develop
Expected result
Site should compile
Actual result
Environment
Can't seem to get
gatsby info
to work π€here's the gatsby-named items from the yarn.lockFile contents (if changed)
gatsby-config.js
:package.json
:gatsby-node.js
:gatsby-browser.js
:gatsby-ssr.js
: