graphql-tools icon indicating copy to clipboard operation
graphql-tools copied to clipboard

Issue: SyntaxError when using @graphql-tools/import with Node.js (v20 or v22)

Open winverse opened this issue 1 year ago • 0 comments

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • [ ] 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox

    Make sure to fork this template and run yarn generate in the terminal.

    Please make sure the GraphQL Tools package versions under package.json matches yours.

  • [ ] 2. A failing test has been provided
  • [ ] 3. A local solution has been provided
  • [ ] 4. A pull request is pending review

Describe the bug

When attempting to run a project that uses @graphql-tools/import, a SyntaxError is thrown indicating that the process module does not provide an export named cwd. This error occurs when importing the cwd function from the process module.

To Reproduce Steps to reproduce the behavior:

Steps to reproduce the behavior:

Set up a project using @graphql-tools/import. Use Node.js v20.11.1. or v22.2.0 Attempt to run the project. Observe the following error:

file:/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-tools/import/esm/index.js:3
import { cwd as cwdFactory } from 'process';
              ^^^
SyntaxError: The requested module 'process' does not provide an export named 'cwd'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12)

Expected behavior

The project should run without errors, correctly importing and using the cwd function from the process module.

Environment:

  • OS: Mac (Sonoma 14.5) @graphql-tools/import: 7.0.1 NodeJS: v20.11.1

Additional context

It seems like the ESM implementation in Node.js does not support named exports from the process module as expected by @graphql-tools/import. This issue might require changes in how the process module is imported or an update to the @graphql-tools/import package to support the latest Node.js versions.

Thank you for looking into this issue!

winverse avatar May 31 '24 07:05 winverse