gatsby-uc / gatsby-source-strapi

Gatsby source plugin for building websites using Strapi as a data source
MIT License
354 stars 182 forks source link

ERROR #11321 PLUGIN "gatsby-source-strapi" threw an error while running the sourceNodes lifecycle: connect ECONNREFUSED ::1:1337 #349

Closed prathameshjchavan closed 2 years ago

prathameshjchavan commented 2 years ago

Screenshot (1)

prathameshjchavan commented 2 years ago

$ npm run develop

gatsby-starter-default@0.1.0 develop gatsby develop -H 192.168.0.103

success compile gatsby files - 55.729s success load gatsby config - 0.317s success load plugins - 14.000s Loaded gatsby-source-strapi-plugin success onPreInit - 0.149s success initialize cache - 1.033s success copy gatsby files - 5.661s success Compiling Gatsby Functions - 14.572s success onPreBootstrap - 15.156s success createSchemaCustomization - 0.020s

ERROR #11321 PLUGIN

"gatsby-source-strapi" threw an error while running the sourceNodes lifecycle:

connect ECONNREFUSED ::1:1337

Error: connect ECONNREFUSED ::1:1337

warn The gatsby-source-strapi plugin has generated no Gatsby nodes. Do you need it? This could also suggest the plugin is misconfigured. success Checking for changed pages - 0.001s success source and transform nodes - 1.509s success building schema - 0.673s success createPages - 0.007s success createPagesStatefully - 0.324s info Total nodes: 109, SitePage nodes: 9 (use --verbose for breakdown) success Checking for changed pages - 0.001s success write out redirect data - 0.003s success onPostBootstrap - 0.006s info bootstrap finished - 232.403s success onPreExtractQueries - 0.001s

ERROR #85923 GRAPHQL

There was an error in your GraphQL query:

Cannot query field "allStrapiProduct" on type "Query".

If you don't expect "allStrapiProduct" to exist on the type "Query" it is most likely a typo. However, if you expect "allStrapiProduct" to exist there are a couple of solutions to common problems:

It is recommended to explicitly type your GraphQL schema if you want to use optional fields.

File: src\components\home\PromotionalProducts.js:16:7

See our docs page for more info on this error: https://gatsby.dev/creating-type-definitions

ERROR #85923 GRAPHQL

There was an error in your GraphQL query:

Cannot query field "allStrapiProduct" on type "Query".

If you don't expect "allStrapiProduct" to exist on the type "Query" it is most likely a typo. However, if you expect "allStrapiProduct" to exist there are a couple of solutions to common problems:

It is recommended to explicitly type your GraphQL schema if you want to use optional fields.

File: src\components\home\FeaturedProducts.js:19:7

See our docs page for more info on this error: https://gatsby.dev/creating-type-definitions

ERROR #85923 GRAPHQL

There was an error in your GraphQL query:

Cannot query field "allStrapiCategory" on type "Query".

If you don't expect "allStrapiCategory" to exist on the type "Query" it is most likely a typo. However, if you expect "allStrapiCategory" to exist there are a couple of solutions to common problems:

It is recommended to explicitly type your GraphQL schema if you want to use optional fields.

File: src\components\ui\layout.js:10:7

See our docs page for more info on this error: https://gatsby.dev/creating-type-definitions

failed extract queries from components - 7.051s success write out requires - 0.043s success run static queries - 0.057s - 1/1 17.45/s success run page queries - 0.029s - 3/3 103.88/s

ERROR

Module not found: Error: Can't resolve '../../../public/page-data/sq/d/2105022444.json' in 'D:\React Projects\var_x\frontend\src\components\home'

ModuleNotFoundError: Module not found: Error: Can't resolve '../../../public/p age-data/sq/d/2105022444.json' in 'D:\React Projects\var_x\frontend\src\compon ents\home'

Module not found: Error: Can't resolve '../../../public/page-data/sq/d/2611317079.json' in 'D:\React Projects\var_x\frontend\src\components\home'

ModuleNotFoundError: Module not found: Error: Can't resolve '../../../public/p age-data/sq/d/2611317079.json' in 'D:\React Projects\var_x\frontend\src\compon ents\home'

Module not found: Error: Can't resolve '../../../public/page-data/sq/d/3765042692.json' in 'D:\React Projects\var_x\frontend\src\components\ui'

ModuleNotFoundError: Module not found: Error: Can't resolve '../../../public/p age-data/sq/d/3765042692.json' in 'D:\React Projects\var_x\frontend\src\compon ents\ui'

not finished Building development bundle - 39.018s

laurenskling commented 2 years ago

The plugin is trying to connect the a local server on port 1337, which is probably not running

agentraghav commented 2 years ago

@laurenskling , strapi server is running on localhost:1337, but it still show the same error, i am using gatsby v4, if i switch to gatsby v2 it works smooth, but i want it working with v4. i am facing the same issue :(

bureauberg commented 2 years ago

Just to be sure, in Strapi 4 an API token is mandatory now. Did you add a full-access API token to Strapi first (Settings > API Tokens)? Then copy the token and paste it to a (new) env.development file in the Gatsby root. See https://www.gatsbyjs.com/plugins/gatsby-source-strapi/

Hope it helps, Jacco

prathameshjchavan commented 2 years ago

The problem has been solved. Thanks for your suggestions. I've tried all of them and would definitely help to fix this issue. But, this error is caused due to mismatch file name in my gatsby imports. I had a file named HeroBlock.js in my working directory which I was importing as heroblock.js in my code.

Sometimes, It was successfully compiling by downgrading Gatsby version. But, it doesn't worked as expected like it was not performing hot reloading while development and would only change after server restarts. Such typos in the code wouldn't get compiled with the latest Gatsby version and throws the above error stack.

It was such a hard time for me to figure out the typo as there was no error message indicating the same. Thanks for your support and do consider this solution if you get such errors.