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

Error: No "exports" main defined in /path/to/the/repo/node_modules/@middy/core/package.json #1210

Closed
bornster opened this issue May 9, 2024 · 1 comment
Labels

Comments

@bornster
Copy link

bornster commented May 9, 2024

After updating middy/core and its connected packages (ex. middy/http-content-negotiation,middy/http-cors) from 4.x.x to 5.x.x encountered a new error during endpoint testing of Lambda handlers. Most likely an issue coming from the removal of support for CommonJS. For the lambda deployment I am using serverless.

const getListHandler = async (event, context) => {
  return {
                statusCode: 200,
                body: "Hello World"
            };
};

export const getList = middy(getListHandler)
    .use(cors())
    .use(httpSecurityHeaders());

Error: No "exports" main defined in /path/to/the/repo/node_modules/@middy/core/package.json

tsconfig.json 
{
  "extends": "./tsconfig.paths.json",
  "display": "Node 18 + ESM + Strictest",
  "compilerOptions": {
    "lib": ["es2020"],
    "target": "esnext",
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "alwaysStrict": true,
    "checkJs": true,
    "declaration": true,
    "esModuleInterop": true,
    "exactOptionalPropertyTypes": false,
    "forceConsistentCasingInFileNames": true,
    "moduleResolution": "node",
    "noEmitOnError": false,
    "noFallthroughCasesInSwitch": true,
    "noImplicitAny": true,
    "noImplicitOverride": true,
    "noImplicitReturns": true,
    "noPropertyAccessFromIndexSignature": true,
    "noUncheckedIndexedAccess": false,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "outDir": "build",
    "pretty": true,
    "removeComments": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "strictFunctionTypes": true,
    "strictNullChecks": true,
    "strictPropertyInitialization": true
  },
  "ts-node": {
    "require": ["tsconfig-paths/register"]
  }
}
  • Node.js: [18.12.0]
  • Middy: [5.3.2]
  • Serverless [3.38.0]
@bornster bornster added the bug label May 9, 2024
@bornster bornster closed this as completed May 9, 2024
@bornster bornster reopened this May 9, 2024
@willfarrell
Copy link
Member

Is this dup of #1208 ?

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

No branches or pull requests

2 participants