diff --git a/packages/gatsby/src/internal-plugins/query-runner/graphql-errors.js b/packages/gatsby/src/internal-plugins/query-runner/graphql-errors.js index 701850fe029fe..2457d06fea31c 100644 --- a/packages/gatsby/src/internal-plugins/query-runner/graphql-errors.js +++ b/packages/gatsby/src/internal-plugins/query-runner/graphql-errors.js @@ -176,18 +176,18 @@ export function graphqlError( ) } - message = `There was an error while compiling your site's GraphQL queries. - ${message} + let reportedMessage = `There was an error while compiling your site's GraphQL queries. + ${message || error.message} ` + if (error.message.match(/must be an instance of/)) { - message += + reportedMessage += `This usually means that more than one instance of 'graphql' is installed ` + `in your node_modules. Remove all but the top level one or run \`npm dedupe\` to fix it.` } if (error.message.match(/Duplicate document/)) { - message += `${error.message.slice(21)}\n` + reportedMessage += `${error.message.slice(21)}\n` } - - return message + return reportedMessage }