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

Module not found: Error: Package path . is not exported from package #1143

Closed
lBroth opened this issue Nov 27, 2023 · 1 comment
Closed

Module not found: Error: Package path . is not exported from package #1143

lBroth opened this issue Nov 27, 2023 · 1 comment

Comments

@lBroth
Copy link

lBroth commented Nov 27, 2023

Describe the bug
I encountered the following error:
Module not found: Error: Package path . is not exported from package node_modules/@middy/core (see exports field in node_modules/@middy/core/package.json).

To Reproduce
In my tsconfig.json file, I set the following configuration:

"module": "commonjs",
"moduleResolution": "node"

This issue arises when using TypeScript version 4.8.4 in conjunction with webpack.

Expected behavior
I resolved the problem by applying the following patch to the package.json file of the @middy/core module:

diff --git a/node_modules/@middy/core/package.json b/node_modules/@middy/core/package.json
index fc07d5e..b38f5de 100644
--- a/node_modules/@middy/core/package.json
+++ b/node_modules/@middy/core/package.json
@@ -16,6 +16,10 @@
       "import": {
         "types": "./index.d.ts",
         "default": "./index.js"
+      },
+      "require": {
+        "types": "./index.d.ts",
+        "default": "./index.js"
        }
     }
   },

Environment:

  • Node.js: [18]
  • Middy: [5.0.3]

Additional context
@willfarrell @lmammino, if it's acceptable to you, I can create a pull request for the suggested changes.

Thanks

@lBroth lBroth added the bug label Nov 27, 2023
@willfarrell
Copy link
Member

Thanks for reporting and suggesting a fix.

As announced over a year ago, CommonJS is no longer supported with the latest release, v5. AWS Lambda can run ESM natively and benchmarks show it out performs CJS. So, updating is recommended. If you need CJS support, v4.x is an option (currently has no reported security vulnerabilities).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants