DOP-C02 SDLC Automation Practice Question
A DevOps engineer is troubleshooting a failed build in AWS CodeBuild. The build log shows: 'Error: Cannot find module 'lodash'.' The buildspec.yml file lists 'npm install' as a command. What is the most likely cause?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The package.json file is missing or does not include lodash.
The error 'Cannot find module 'lodash'' indicates that the lodash package is not installed. Since the buildspec includes 'npm install', the most likely cause is that the package.json file is missing or does not list lodash as a dependency. Without package.json or with incorrect dependencies, npm install will not install lodash, leading to the error.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The npm install command is running before the source is downloaded.
Why it's wrong here
CodeBuild automatically downloads the repository source code before any build commands are executed. The build phases run in a fixed order: source checkout happens before install, so the workspace always contains the downloaded source when `npm install` starts. If the source were somehow absent, the install phase could not even find `package.json`, producing a different error about a missing manifest, not a missing module.
- ✗
The lodash package is not compatible with the Node.js version.
Why it's wrong here
If lodash were incompatible with the configured Node.js version, `npm install` would typically fail with an `engine` warning or a compile-time error, and the build would stop before producing an artifact. A "Cannot find module 'lodash'" runtime error indicates the package was never installed into `node_modules`, which is a dependency declaration or installation problem, not a version compatibility problem.
- ✓
The package.json file is missing or does not include lodash.
Why this is correct
`npm install` reads the `dependencies` and `devDependencies` fields in `package.json` and installs exactly the packages listed there. If lodash is not specified in that file, it will not be installed, and any subsequent `require('lodash')` or `import ... from 'lodash'` will throw `MODULE_NOT_FOUND`. A missing `package.json` would cause `npm install` to fail outright, but either way, the root cause is that lodash was not properly declared as a dependency.
- ✗
The build environment does not have internet access to download packages.
Why it's wrong here
Packages are downloaded from the npm registry during the install phase. If the build environment had no internet access, `npm install` would fail with a network error such as `ENOTFOUND`, `ETIMEDOUT`, or an `ECONNREFUSED` — not a module-not-found error at build time. The error message about lodash being missing means the install step either did not include lodash or was skipped for that package, not that network connectivity was the issue.
Go deeper
Related to this question
About these practice questions
Courseiva writes every DOP-C02 question from scratch — 1,298 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DOP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DOP-C02 exam.