aws-samples / generative-ai-cdk-constructs-samples

This repo provides sample generative AI stacks built atop the AWS Generative AI CDK Constructs.
https://github.com/awslabs/generative-ai-cdk-constructs
Apache License 2.0
78 stars 17 forks source link

Can't deploy - error TS2307: Cannot find module 'aws-cdk-lib' or its corresponding type declarations. #47

Closed nicolasduminil closed 6 months ago

nicolasduminil commented 6 months ago

I'm trying to follow the README.md instructions to deploy he sagemaker-jumpstart-model project. The command cdk deploy fails raising the exception below:

XPS-15-9570:~/generative-ai-cdk-constructs-samples/samples/sagemaker_jumpstart_model$ cdk deploy
npm WARN exec The following package was not found and will be installed: ts-node@10.9.2
/home/nicolas/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:859
        return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
bin/sagemaker_jumpstart_model.ts:15:22 - error TS2307: Cannot find module 'aws-cdk-lib' or its corresponding type declarations.

15 import * as cdk from 'aws-cdk-lib';
                        ~~~~~~~~~~~~~

    at createTSError (/home/nicolas/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/home/nicolas/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/home/nicolas/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/home/nicolas/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/home/nicolas/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1617:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
    at Object.require.extensions.<computed> [as .ts] (/home/nicolas/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1019:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {
  diagnosticCodes: [ 2307 ]
}

All the prerequisites are satisfied, as shown below:

$ node --version
v18.20.0
$ cdk version
2.134.0 (build 265d769)
$ jq --version
jq-1.6

What did I miss here ?

Kind regards,

Nicolas

nicolasduminil commented 6 months ago

Anyone ?

krokoko commented 6 months ago

Hi @nicolasduminil , thank you for reporting this issue. What is the output of npm i?

scottschreckengaust commented 6 months ago

Hello @ nicolasduminil, sorry for the inconvenience. The npm install step was missing from the README.md. The pull request, #49, has that update.

nicolasduminil commented 5 months ago

Hello, Many thanks for the update. Here is the new exception raised while running cdk deploy command:

$ cdk bootstrap aws://49.../eu-west-3

⏳ Bootstrapping environment aws://49.../eu-west-3... Trusted accounts for deployment: (none) Trusted accounts for lookup: (none) Using default execution policy of 'arn:aws:iam::aws:policy/AdministratorAccess'. Pass '--cloudformation-execution-policies' to customize. CDKToolkit: creating CloudFormation changeset... ✅ Environment aws://49.../eu-west-3 bootstrapped.

$ cdk deploy

✨  Synthesis time: 3.8s

current credentials could not be used to assume 'arn:aws:iam::49...:role/cdk-hnb659fds-deploy- role-49...-us-east-1', but are for the right account. Proceeding anyway.
current credentials could not be used to assume 'arn:aws:iam::49...:role/cdk-hnb659fds-deploy-role-495913029085-us-east-1', but are for the right account. Proceeding anyway.

 ❌ Deployment failed: Error: SagemakerJumpstartModelStack: SSM parameter /cdk-bootstrap/hnb659fds/version not found. Has the environment been bootstrapped? Please run 'cdk bootstrap' (see https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html)
at Deployments.validateBootstrapStackVersion (/usr/local/lib/node_modules/aws-cdk/lib/index.js:436:12032)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Deployments.buildSingleAsset (/usr/local/lib/node_modules/aws-cdk/lib/index.js:436:10797)
at async Object.buildAsset (/usr/local/lib/node_modules/aws-cdk/lib/index.js:436:196976)
at async /usr/local/lib/node_modules/aws-cdk/lib/index.js:436:180802

SagemakerJumpstartModelStack: SSM parameter /cdk-bootstrap/hnb659fds/version not found. Has the environment been bootstrapped? Please run 'cdk bootstrap' (see https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html)

The error seems to state that the environment hasn't been bootstrapped, but it was. What might be wrong again here ? I can see that, despite of having correctly configured my region as being eu-west-3, it tries to use us-east-1.

Many thanks in advance.

krokoko commented 5 months ago

Hi @nicolasduminil , did you update the region in samples/sagemaker_jumpstart_model/bin/sagemaker_jumpstart_model.ts ?