moltin / gatsby-source-moltin

🚀 Gatsby source plugin for building Elastic Path Commerce Cloud powered eCommerce websites
https://www.gatsbyjs.org/packages/@moltin/gatsby-source-moltin
MIT License
21 stars 4 forks source link

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

Open kailash-chander07 opened 4 years ago

kailash-chander07 commented 4 years ago

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

⠦ 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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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

kailash-chander07 commented 4 years ago

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

samblacklock commented 4 years ago

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