aws-cdk: link-all.sh not working as expected
Describe the issue
I’m following the contribution guide:
- I cloned the repository
- ran the
npx lerna run build --skip-nx-cache - created a fresh CDK TS-based app
- and ran
link-all.shscript
Even though I see the linking script to do symlinks, I still see:
$ npx cdk --version
2.1006.0 (build a3b9762)
instead of 0.0.0. When I tried to do:
$ rm -rf node_modules
$ npx cdk --version
Need to install the following packages:
cdk@2.1017.1
Ok to proceed? (y)
It seems like it’s not seeing the locally built CDK version. I even went through my system, cleaned up stale aws-cdk versions but it didn’t help. Anything obvious I am missing here?
Links
https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md#linking
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 19 (17 by maintainers)
Commits related to this issue
- docs: reflect aws-cdk-lib and CLI split in the contribution guide (#34633) Remove references to `cdk --version` check since this doesn't work now after CLI split from aws-cdk. Closes #34610 ---- ... — committed to aws/aws-cdk by rantoniuk a year ago
- docs: reflect aws-cdk-lib and CLI split in the contribution guide (#34633) Remove references to `cdk --version` check since this doesn't work now after CLI split from aws-cdk. Closes #34610 ---- ... — committed to aws/aws-cdk by rantoniuk a year ago
@mrgrain
Hi! I’m running into a similar issue, where after the
link-all.shcall, I am no longer able to runnpx cdk deployThe response is like so:
I was trying to develop a local feature by building it myself, then linking it to the app, so that my app calls my modified version.
I have called
npx lerna run buildin the main cdk directory to ensure that everything was built before I tried to runnpx cdk deploy. I can confirm thatnpx cdk deploywas working if I install a fresh cdk vianpm install aws-cdk@latest.Not sure if I’m missing anything here?
Edit: I tried removing the flag
--prefer-ts-extsfromcdk.json, as suggested above.Now everything works. Thanks a lot!
Nice.
Fundamentally, this is a choice you are making (but potentially being unaware of it) because of the app command you are using (which again, is probably because that’s the default from
cdk initand it makes a lot of sense for end-users). As a reminder, the app command is:So the short answer to all of your questions is: This is how
ts-nodeworks.ts-nodeand therefore TypeScript runs in the context of your app. Unless your app is using Project References, TypeScript doesn’t use any other config files. That’s even if they seem to be more appropriate or are located closer to a source.--prefer-ts-extsinstructsts-nodeto prefer a TS file over a js file. This also applies to imported files. From TS perspective, files insidenode_modulesaren’t special. There’s another part oftscthat handles the “translation” from package nameaws-cdk-libto physical import path. But after that conversion it’s just the same.Because that’s not how
excludeworks: https://www.typescriptlang.org/tsconfig/#excludeRight, thanks for the clarification.
Can you share these errors? They seem to be the core of the issue. Can you also confirm if at this point
npx cdk versionworks and what it returns?Edit: Apologies, I see you’ve already posted the errors. Bear with me.
You certainly don’t need this step. In fact - and like you’ve discovered - it will undo the linking. It’s not needed because
link-all.shshould not change anything with regards to the CLI.