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

Guide for generating nexus in ESM #1155

Open
hyochan opened this issue Apr 4, 2023 · 1 comment
Open

Guide for generating nexus in ESM #1155

hyochan opened this issue Apr 4, 2023 · 1 comment

Comments

@hyochan
Copy link

hyochan commented Apr 4, 2023

Hi! Thanks for awesome library nexus. I've been using this for many years now.
Today, I am looking to upgrade our project to ESM and I am stuck in error when generating nexus.

It shows the below error.

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/hyo/Github/app/server/src/schema.ts
    at new NodeError (node:internal/errors:399:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:79:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:121:38)
    at defaultLoad (node:internal/modules/esm/load:81:20)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:605:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:64:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:480:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

And this is because I change the type to module in package.json. This error can be found in https://stackoverflow.com/questions/63386054/typeerror-err-unknown-file-extension-unknown-file-extension-ts-on-visual-s.

I tried to look over the document in the repo but I can't find anywhere to generate nexus safely when type: module is on.
I hope I can get help on setting up nexus with ESM!

Thanks in advance.

@binary64
Copy link

Use esbuild to compile it first

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

2 participants