I have an AWS CDK v2 project and can successfully synth when I import a local npm package by adding the following to package.json:
"@my/constructs": "file:../my/dist/packages/constructs"
This package resides in a separate Nx monorepo.
I have another package in the Nx monorepo "@my/coolthing"
When I import "@my/coolthing" into "@my/constructs" I get an AWS CDK synth error: Cannot find module '@my/coolthing'.
The "@my/constructs" package.json lists "@my/coolthing" correctly in peerDependencies i.e.
"peerDependencies": {
"@my/coolthing": "1.0.0"
}
How can I get the CDK to synth successfully?
Things I've tried:
- Manually copying the "@my/coolthing" directory to the CDK node_modules folder.
- Publishing "@my/coolthing" to NPM and doing an NPM install in the CDK project.