Simple lib import fails with both `tsx` and `ts-node`
uqee opened this issue · comments
Describe the bug
node:internal/modules/esm/resolve:303
return new ERR_PACKAGE_PATH_NOT_EXPORTED(
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in .../node_modules/@middy/core/package.json
at exportsNotFound (node:internal/modules/esm/resolve:303:10)
at packageExportsResolve (node:internal/modules/esm/resolve:593:13)
at resolveExports (node:internal/modules/cjs/loader:591:36)
at Module._findPath (node:internal/modules/cjs/loader:668:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1130:27)
at a._resolveFilename (.../node_modules/.pnpm/tsx@4.7.1/node_modules/tsx/dist/cjs/index.cjs:1:1729)
at Module._load (node:internal/modules/cjs/loader:985:27)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at <anonymous> (/Users/dz/Documents/more/moreai/back-users/f.ts:1:24) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
To Reproduce
- CodeSandBox
- npm install
- npm start
Expected behaviour
- no error
Environment (please complete the following information):
- Node.js: 20.9.0 (also tested on 20.11.1)
- Middy: 5.2.4
- AWS SDK: none
Additional context
ts-node
shows the same error- this bug blocks CDK deploy
No "exports" main defined in
usually means you're trying to use ESM with CJS. Middy v4.x does support CJS, v5 does not.
Ok, will migrate to ESM and test again, thank you!