Prevent security vulnerabilities arising from dependencies that cannot be upgraded
/my-project
│── /node_modules <-- 🚨 Dependencies added to the project
│ ├── lodash/
│ ├── express/
│ └── axios/
│── index.js
Dependencies are downloaded and added directly to the project without using a version manager.
In this example, the node_modules folder with three dependencies was added to the project, but there is no package.json file.
/my-project
│── .gitignore
node_modules/
│── package.json
{
"dependencies": {
"lodash": "4.17.21",
"express": "4.19.2",
"axios": "1.4.0"
}
}
Dependencies are defined in a package.json file so that a package manager like npm or yarn can track them and identify if they need updates.
Additionally, the node_modules folder is excluded in the .gitignore file to prevent it from being added to the repository. When cloning the repository, dependencies must be installed using npm install.