core: ./core is not exported in package.json
See original GitHub issueWhat is the problem?
When migrating to cdk 2.1.0, i have the following error:
Error: Package subpath ‘./core’ is not defined by “exports” in /…/node_modules/aws-cdk-lib/package.json
(and actually, it is not in the package.json)
Reproduction Steps
In my code:
import { CfnOutput, SecretValue, Stage, Stack } from 'aws-cdk-lib/core';
Use cdk 2.1.0 in package.json:
"devDependencies": {
"aws-cdk": "2.1.0",
},
"dependencies": {
"aws-cdk-lib": "2.1.0",
"constructs": "10.0.12",
}
Then try to synthesise:
cdk synth
Gives the error:
Error: Package subpath ‘./core’ is not defined by “exports” in /…/node_modules/aws-cdk-lib/package.json
What did you expect to happen?
I expected to have get the template synthesised.
What actually happened?
The following error (line 18 is the import statement above):
Error: Package subpath ‘./core’ is not defined by “exports” in /…/node_modules/aws-cdk-lib/package.json at new NodeError (node:internal/errors:371:5) at throwExportsNotFound (node:internal/modules/esm/resolve:416:9) at packageExportsResolve (node:internal/modules/esm/resolve:669:3) at resolveExports (node:internal/modules/cjs/loader:482:36) at Function.Module._findPath (node:internal/modules/cjs/loader:522:31) at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Module.require (node:internal/modules/cjs/loader:999:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (/…/bin/mycode.ts:18:1)
CDK CLI Version
2.1.0
Framework Version
No response
Node.js Version
v17.0.1
OS
mac OS BigSur (M1)
Language
Typescript
Language Version
TypeScript 4.5.2
Other information
Manually adding “./core”: “./core/index.js” to the node_modules/aws-cdk-lib/package.json solve the issue, but this is not a viable solution.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:10
- Comments:14 (7 by maintainers)
Top GitHub Comments
In CDK v2 all
@aws-cdk/core
exports are now direct exports ofaws-cdk-lib
The following should work:
import { CfnOutput, SecretValue, Stage, Stack } from 'aws-cdk-lib';
@ryparker 's fix works fine
aws-cdk-lib/core
->aws-cdk-lib
Edit* adding more info
to