graphql-zeus
graphql-zeus copied to clipboard
Getting ERR_UNSUPPORTED_DIR_IMPORT when generating
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.
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",
}
}
This is still a problem, config-maker package that has this issue was last updated a year, zeus shouldn't be using packages that are not well maintained, and which don't allow PRs to fix issues as well since their code is not public
config-maker is public MIT
https://github.com/aexol-studio/config-maker