Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting ERR_UNSUPPORTED_DIR_IMPORT when generating #402

Open
Rdeisenroth opened this issue Jul 15, 2024 · 1 comment
Open

Getting ERR_UNSUPPORTED_DIR_IMPORT when generating #402

Rdeisenroth opened this issue Jul 15, 2024 · 1 comment

Comments

@Rdeisenroth
Copy link

Hi, on all of my machines, when i run zeus src/backend/prisma/generated/schema.graphql src/backend/prisma/generated/zeus --typescript --apollo, i get the following error (<repo_path> is a placeholder for the actual pwd):

node:internal/process/esm_loader:40
      internalBinding('errors').triggerUncaughtException(
                                ^

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '<repo_path>/node_modules/rxjs/operators' is not supported resolving ES modules imported from <repo_path>/node_modules/config-maker/lib/utils/AwfulAutoCompletePrompt.js
Did you mean to import rxjs/operators/index.js?
    at finalizeResolution (node:internal/modules/esm/resolve:249:11)
    at moduleResolve (node:internal/modules/esm/resolve:908:10)
    at defaultResolve (node:internal/modules/esm/resolve:1121:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
    at link (node:internal/modules/esm/module_job:84:36) {
  code: 'ERR_UNSUPPORTED_DIR_IMPORT',
  url: 'file://<repo_path>/node_modules/rxjs/operators'
}

it can be fixed, if i manually edit AwfulAutoCompletePrompt.js, line 11:

-import { takeWhile } from 'rxjs/operators';
+import { takeWhile } from 'rxjs/operators/index.js';

However the error always reappears when i install another package with yarn add.

@Rdeisenroth
Copy link
Author

Rdeisenroth commented Jul 25, 2024

As a temporary workaround, i added a file called postinstall.ts to src/scripts:

import * as fs from 'fs';
import * as path from 'path';

// See https://github.com/graphql-editor/graphql-zeus/issues/402
const filePath = path.resolve('node_modules/config-maker/lib/utils/AwfulAutoCompletePrompt.js');
const fileContent = fs.readFileSync(filePath, 'utf8');

const fixedContent = fileContent.replace(
    "import { takeWhile } from 'rxjs/operators';",
    "import { takeWhile } from 'rxjs/operators/index.js';"
);

fs.writeFileSync(filePath, fixedContent, 'utf8');
console.log('Fixed rxjs import in AwfulAutoCompletePrompt.js');

and edited my package.json like so:

{
  "scripts": {
    "postinstall": "ts-node --require tsconfig-paths/register --require reflect-metadata src/scripts/postinstall.ts",
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant