-
-
Notifications
You must be signed in to change notification settings - Fork 377
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
Type middy.MiddlewareFn doesn't exist #1147
Comments
I see it in @middy/core/index.d.ts
I'm not sure why it wouldn't be showing up for you. |
When importing and using @middy/core in my Node.js AWS Lambda application, I am running into the following error:
Steps to Reproduce
Cause When this "exports" mapping is not defined, Node is unable to resolve the import request properly at runtime. |
@willfarrell - VSCode doesn't seem to think so. ![]() ![]() |
I'm having this same issue with /@middy/http-json-body-parser/package.json
|
@meganmajewski, I resolved the issue by updating the CommonJS usage as mentioned in the updated documentation for Middy. They've made changes from the previous usage, so review the migration guide from v4 to v5 for more details. |
Same error Here! @Valvide how do you resolve the issue ? |
Having this same issue with @middy/http-json-body-parser Error:
|
Hello all, sorry for the delay in addressing this. I have tried to replicate the issue and I might have a possible solution in a branch. Could you try to install npm install 'https://gitpkg.now.sh/middyjs/middy/packages/core?fix-1147' or by setting the following in your {
"dependencies": {
"@middy/core": "https://gitpkg.now.sh/middyjs/middy/packages/core?fix-1147"
}
} It might also be useful to see what your {
"compilerOptions": {
"target": "es2020",
"strict": true,
"preserveConstEnums": true,
"noEmit": true,
"sourceMap": false,
"module":"es2015",
"moduleResolution":"node",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
},
"exclude": ["node_modules", "**/*.test.ts"]
} If this helps fix your issue, we can create a PR, do a more formal review, and make sure the changes land in a new release. Thanks Note Please note that we are not TypeScript experts and maintaining correct types and typescript configuration and docs is always something we struggle with. If someone wants to help to maintain that part more proactively we would love that. |
@lmammino That didnt work for me... |
@lmammino Same error from my side: |
That's interesting because I haven't changed that package (I only touched Either way... thanks to @mkarsene, @david-eolas, and @jobuit for testing this change. Could you be so kind to share your TSConfig or, even better, a minimal reproducible example that I can use as a starting point to try to resolve the issue. I am afraid that different versions of typescript and different TSConfig files might lead to very different results, so we would just keep guessing if we don't work on specific shared examples... |
AWS lambda is throwing:
I tried adding core still get the No "exports" error:
I’ve also tried various module ways to reference it (since I just need the httpMultipartBodyParser) but to no avail.
and then:
Here is my index.js:
Here is my AWS lambda config:
Fyi, removing all references to middy and adding the following into my lambda confirms the AWS lambda's are currently using node version: v20.11.0:
This logging shows the following in CloudWatch:
I have a super simple set up so anyone can easily reproduce the error:
Below is the full CloudWatch error:
|
@RickDir Middy v5 doesn't support CommonJS, v4 does if you're unable to update to ESM yet. |
Thanks @willfarrell Testing with ESM exposed the install instructions I got were lacking as well (throws: Cannot find package '@middy/util') I’ll have to dive deeper into the documentation to make sure I'm starting off correctly. Thanks again |
Hi all, someone has resolved the issue? I'm encountering it with middy/core 5.3.1 |
Installing |
We think this should be resolved in 5.3.3. Please reopen if now |
It is not resolved in 5.3.3, at least for my situation. However, I've been able to get around it. I figure this might act as a clue to the ultimate fix. The key was that it works fine, except when I do something like this:
When I get rid of the direct reference and
|
I'm running into the same thing on the latest version of Middy
My Lambda function does a simple export like this and we're using ESM now
|
I am also encountering this issue. I've tried Edit: Yep. Middy stuff does not enjoy being imported from another package within my pnpm monorepo... Not sure why that is though |
I'm using v5 of middy and reading these docs on custom middleware. https://middy.js.org/docs/writing-middlewares/with-typescript
But middy.MiddlewareFn isn't available.
The text was updated successfully, but these errors were encountered: