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

ESM module not working in Jest #22

Closed
djMax opened this issue May 26, 2023 · 1 comment
Closed

ESM module not working in Jest #22

djMax opened this issue May 26, 2023 · 1 comment

Comments

@djMax
Copy link

djMax commented May 26, 2023

There are so very many moving parts. But after converting a project to ESM, I cannot run jest anymore for this package.

    Details:

    /oss/service/node_modules/read-pkg-up/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import path from 'node:path';
                                                                                      ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      2 |
      3 | import dotenv from 'dotenv';
    > 4 | import { readPackageUp } from 'read-pkg-up';
        | ^
      5 | import type { NormalizedPackageJson } from 'read-pkg-up';

You can see it fail here:
https://github.com/openapi-typescript-infra/service/tree/djmax/esm

I also can't eslint anymore, but one thing at a time. I'm mostly making the ESM move because you have so many packages and they are all ESM. I've tried a few times in the past year and failed each time. I'm hoping someone will have pity on me and perhaps I won't fail yet again.

@sindresorhus
Copy link
Owner

You should open an issue on Jest instead. This package is 100% correct ESM and the issue is not here.

@sindresorhus sindresorhus closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2023
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