In https://github.com/directus/gatsby-source-directus/pull/26 it was added a feature to retry requests.
This feature depends on node-fetch so it was installed the latest version of this package.
Although version 3.x of node-fetch is ESM only and when trying to run gatsby develop the following error appears:
Error: [ERR_REQUIRE_ESM]: require() of ES Module /tmp/gatsby-directus/node_modules/.pnpm/node-fetch@3.3.1/node_modules/node-fetch/src/index.js from /private/tmp/gatsby-directus/node_modules/.pn
pm/@directus+gatsby-source-directus@9.16.0_eslint@8.44.0_gatsby-source-filesystem@5.11.0_gatsby-source-graphql@5.11.0/node_modules/@directus/gatsby-source-directus/gatsby-node.js not supported.
Instead change the require of index.js in /tmp/gatsby-directus/node_modules/.pnpm/@directus+gatsby-source-directus@9.16.0_eslint@8.44.0_gatsby-source-filesystem@5.11.0_gatsby-source-graphql@5.1
1.0/node_modules/@directus/gatsby-source-directus/gatsby-node.js to a dynamic import() which is available in all CommonJS modules.
Solution
In https://github.com/directus/gatsby-source-directus/pull/28 there's an attempt to overcome this issue by implementing the dynamic import.
Although, the recommended solution for now should be to follow other packages that we depend on like gatsby or gatsby-source-graphql which are using version ^2.6.11 of node-fetch
Motivation
In https://github.com/directus/gatsby-source-directus/pull/26 it was added a feature to retry requests. This feature depends on
node-fetch
so it was installed the latest version of this package. Although version 3.x ofnode-fetch
is ESM only and when trying to rungatsby develop
the following error appears:Solution
In https://github.com/directus/gatsby-source-directus/pull/28 there's an attempt to overcome this issue by implementing the dynamic import. Although, the recommended solution for now should be to follow other packages that we depend on like
gatsby
orgatsby-source-graphql
which are using version^2.6.11
ofnode-fetch
Closes https://github.com/directus/gatsby-source-directus/pull/28