Cannot read property 'aws-cdk-lib' of undefined when running npm ci during build stage
chrisammon3000 opened this issue · 3 comments
Describe the bug
npm ci
fails during pipeline build stage. Possibly after updating to version 2.53.0.
Expected Behavior
npm ci
should run and build should complete successfully.
Current Behavior
[Container] 2022/11/30 01:59:31 Phase complete: INSTALL State: SUCCEEDED
--
31 | [Container] 2022/11/30 01:59:31 Phase context status code: Message:
32 | [Container] 2022/11/30 01:59:32 Entering phase PRE_BUILD
33 | [Container] 2022/11/30 01:59:32 Phase complete: PRE_BUILD State: SUCCEEDED
34 | [Container] 2022/11/30 01:59:32 Phase context status code: Message:
35 | [Container] 2022/11/30 01:59:32 Entering phase BUILD
36 | [Container] 2022/11/30 01:59:32 Running command npm ci
37 | npm ERR! Cannot read property 'aws-cdk-lib' of undefined
38 |
39 | npm ERR! A complete log of this run can be found in:
40 | npm ERR! /root/.npm/_logs/2022-11-30T01_59_32_601Z-debug.log
41 |
42 | [Container] 2022/11/30 01:59:32 Command did not exit successfully npm ci exit status 1
43 | [Container] 2022/11/30 01:59:32 Phase complete: BUILD State: FAILED
44 | [Container] 2022/11/30 01:59:32 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm ci. Reason: exit status 1
Reproduction Steps
- Run
npx cdk deploy
after completing the step "Create New Pipeline" in the CDK Workshop for Typescript. - Push changes to CodeCommit repository
- CodePipeline starts a build automatically
Possible Solution
- Deleted package-lock.json
- Deleted node_modules
- Reinstall using
npm install
Additional Information/Context
Before running into this issue I update cdk to 2.53.0
CDK CLI Version
2.53.0 (build 7690f43)
Section
TypeScript Workshop → Advanced Topics → CDK Pipelines → Create New Pipeline
Browser
Chrome
Language
Typescript
Hi. I got this same error when I used a much newer version of npm (9) on my dev machine than what was available in the CodeBuild image (6). I had to explicitly specify a newer build image in my CDK app.
buildEnvironment: {
buildImage: codebuild.LinuxBuildImage.STANDARD_6_0
},
Should be addressed on the latest version of CDK aws/aws-cdk#24544
Let us know if this needs to still be configured on latest version of CDK
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.