Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

TypeError: Cannot read property 'href' of undefined #58

Open
kailash-chander07 opened this issue Sep 15, 2020 · 5 comments
Open

TypeError: Cannot read property 'href' of undefined #58

kailash-chander07 opened this issue Sep 15, 2020 · 5 comments

Comments

@kailash-chander07
Copy link

Hello Guys
I am trying to run the GatsBy build but getting below error. Any help is highly appreciated

gatsby build "debug"

success open and validate gatsby-configs - 0.023 s
success load plugins - 0.563 s
success onPreInit - 0.002 s
success delete html and css files from previous builds - 0.004 s
success initialize cache - 0.037 s
success copy gatsby files - 0.045 s
success onPreBootstrap - 0.007 s
(node:24004) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated

ERROR #11321 PLUGIN

"@moltin/gatsby-source-moltin" threw an error while running the onCreateNode lifecycle:

Cannot read property 'href' of undefined

TypeError: Cannot read property 'href' of undefined

  • gatsby-node.js:346
    [gatsby-demo-store]/[@moltin]/gatsby-source-moltin/gatsby-node.js:346:57

  • Array.filter

  • gatsby-node.js:345 getFileNodes
    [gatsby-demo-store]/[@moltin]/gatsby-source-moltin/gatsby-node.js:345:33

  • gatsby-node.js:373 Object.exports.onCreateNode
    [gatsby-demo-store]/[@moltin]/gatsby-source-moltin/gatsby-node.js:373:32

  • task_queues.js:97 processTicksAndRejections
    internal/process/task_queues.js:97:5

⠦ source and transform nodes
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ build: gatsby build "debug"
npm ERR! Exit status 1
npm ERR!

@samblacklock
Copy link
Collaborator

@kailash-chander07 this is often caused by not having a main image associated with your products. Could you try adding one for each of your products?

@kailash-chander07
Copy link
Author

I can see all the products have main images associated in EP dashboard. After I cleaned and build it is now failing with another error
UNHANDLED REJECTION Encountered an error trying to infer a GraphQL type for: mainImage___NODE. There is no corresponding node with the id field matching: "af0371a1-1f8e-5f2c-9fe0-65ed4edcc9e2".
Error: Invariant Violation: Encountered an error trying to infer a GraphQL type for: mainImage___NODE. There is no corresponding node with the id field matching: "af0371a1-1f8e-5f2c-9fe0-65ed4edcc9e2".

I tried finding this particular id in all products images relationships but no luck. Not sure how this picked this up. Any Idea ?
Can we enhance the error message a little bit more informative to include the some node details.

@samblacklock
Copy link
Collaborator

@kailash-chander07 Can you try yarn run clean && yarn run dev in your gatsby store, if you haven't already?

@kailash-chander07
Copy link
Author

@samblacklock Yes I tried running these multiple time but same error

@samblacklock
Copy link
Collaborator

Hmm @kailash-chander07 this error usually points to cached data somewhere. Could you try to delete your .cache and public folders and rerun the build again

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants