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

Cryptic error message for unrelated MODULE_NOT_FOUND error #9358

Closed
marekryb opened this issue Oct 10, 2024 · 1 comment · Fixed by #9359
Closed

Cryptic error message for unrelated MODULE_NOT_FOUND error #9358

marekryb opened this issue Oct 10, 2024 · 1 comment · Fixed by #9359
Labels

Comments

@marekryb
Copy link
Contributor

// schema.ts
import { list } from '@keystone-6/core'
import { type Lists } from '.keystone/types'
import { value } from 'non-existing-module' // <------

export const lists = {
  Test: list({
    fields: {},
    access: () => value,
  }),
} satisfies Lists

This is compiled without any error by esbuild (.keystone/config.js)

// schema.ts
var import_core = require("@keystone-6/core");
var import_non_existing_module = require("non-existing-module");
var lists = {
  Test: (0, import_core.list)({
    fields: {},
    access: () => import_non_existing_module.value
  })
};

But when you do any keystone command (dev/build), it results in very cryptic message:

(base) exar@exar:~/os/keystone/examples/omit$ pnpm build

> @keystone-6/example-omit@ build /home/exar/os/keystone/examples/omit
> keystone build

🚨 keystone build has not been run
 ELIFECYCLE  Command failed with exit code 1.

Above is simplest reproduction, but actually I am hit by this every now and then in a project where I have paths defined in tsconfig.json. Editor does not report any error since module resolve fine in 'normal' context.

I am pretty sure this returned some actually helpful error message some versions ago. Will check later.

@dcousens
Copy link
Member

Related code can be seen -> https://github.com/keystonejs/keystone/blob/main/packages/core/src/scripts/utils.ts#L16

We aren't filtering errors well enough

@dcousens dcousens changed the title Very cryptic error message when importing inaccessible module Cryptic error message for unrelated MODULE_NOT_FOUND error Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants