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

Cannot find module 'postal-mime' from [PATH] #49

Closed
abhiaiyer91 opened this issue Jun 25, 2024 · 2 comments
Closed

Cannot find module 'postal-mime' from [PATH] #49

abhiaiyer91 opened this issue Jun 25, 2024 · 2 comments

Comments

@abhiaiyer91
Copy link

Hi, I am running some functions that use PostalMime. All is well in my NextJS serverless environment but when I run the tests via Jest I get the following error:

Cannot find module 'postal-mime' from '/path/to/function'

What would be the remedy to this?

@andris9
Copy link
Contributor

andris9 commented Jul 9, 2024

This is some kind of loader issue. PostalMime is a standard ESM module.

@andris9 andris9 closed this as completed Jul 9, 2024
@ValentinH
Copy link

ValentinH commented Jul 24, 2024

I faced the same issue.
We had issue in the past with ESM only packages like query-string and we had to add it to the transformIgnorePatterns config:

  transformIgnorePatterns: [
    // query-string
    // https://github.com/sindresorhus/query-string/issues/366#issuecomment-1580854027
    'node_modules/(?!(query-string)/)',
  ],

However, with postal-mime it doesn't work.
If I manually update the package.json to be:

"exports": {
    "require": "./src/postal-mime.js",
    "import": "./src/postal-mime.js",
    "types": "./postal-mime.d.ts"
},

or

"exports": {
    "default": "./src/postal-mime.js",
    "types": "./postal-mime.d.ts"
},

then it works.

Not sure of the impact of doing this though 🙈

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

3 participants