正解:C
In JavaScript server-side development using Node.js, dependency management is typically handled through package managers such as npm or yarn . These tools categorize installed packages into:
* dependencies - required for running the application in any environment
* devDependencies - required only during development (testing tools, build tools, documentation generators, etc.) When a package is installed using:
yarn add < package > --dev
it is placed under the " devDependencies " section of package.json.
Behavior of Production Mode
Node.js uses the environment variable:
NODE_ENV=production
When this environment variable is set to production, both npm and Yarn follow the standard Node.js convention and skip installing devDependencies . This is done to optimize production builds and reduce deployment size. This is a known and documented behavior in Node.js package management tools.
Therefore, if:
* The developer added the date-manipulation library as a dev dependency , and
* Other team members execute yarn in an environment where NODE_ENV=production is set, then Yarn will not install that dependency because devDependencies are intentionally excluded in production mode.
This explains the behavior described in the question.
Why the Other Options Are Incorrect
Option A:
" YARN_ENV is set to production " is incorrect because Yarn does not use the variable YARN_ENV for dependency installation behavior. Node.js tools use NODE_ENV , not YARN_ENV.
Option B:
This is incorrect because Yarn automatically writes dependencies into package.json. Unlike older npm versions, there is no need for the --save flag.
Option D:
There is no such option as --add. The correct syntax is simply:
yarn add < package >
Missing an option that does not exist cannot be the cause.
JavaScript Knowledge References
* Node.js uses the environment variable NODE_ENV to determine production or development mode.
* Package managers (npm and Yarn) follow the rule that when NODE_ENV=production , only " dependencies " are installed and " devDependencies " are skipped.
* Yarn automatically persists installed packages to package.json without requiring --save.
* Yarn uses the command yarn add to add dependencies; there is no --add flag.