An AEM Developer should add a front-end dependency in the package.json file. The package.json file is a standard configuration file for managing dependencies in JavaScript projects, including those using npm or Yarn as package managers.
Here’s how to add a front-end dependency:
Open the package.json File: This file is typically located at the root of your project.
Add the Dependency: Add the required front-end dependency under the dependencies or devDependencies section. For example, to add lodash as a dependency:
{
"name": "my-aem-project",
"version": "1.0.0",
"dependencies": {
"lodash": "^4.17.21"
}
}
Install the Dependency: Run the following command to install the new dependency:
npm install
Verify Installation: Ensure that the dependency has been added to the node_modules directory and is listed in the package-lock.json file.
The package.json file is the central place to manage all front-end dependencies, making it easy to track, update, and share dependencies across the development team.
References:
These steps ensure that the front-end dependencies are managed efficiently and consistently within the AEM project.