Steps to Setup node_modules Folder
Step 1: To set up the folder let’s first create a directory in our Nodejs project by writing the following commands in our terminal:
mkdir node_project
cd node_project
Step 2: After setting up our project folder, create a package.json file with the command.
npm init -y
Step 3: Now let us add some of the dependencies on which our project depends. As mentioned in the above sections, the npm install package_name command can be used to install our desired package.
npm i express mongoose
Step 4: If for any reason the node_modules folder is not seen, it can be set by running the following command:
npm install
In addition, by storing dependencies locally within the project directory, it ensures that the project is self-contained and can be easily shared or deployed without worrying about external dependencies.
What is the purpose of the ‘node_modules’ folder ?
The node_modules
folder is a directory in NodeJS projects that stores third-party libraries and dependencies. It’s essential for managing dependencies, which are packages or modules that a NodeJS project relies on.
When you install a package using npm or Yarn, these tools download the package along with its dependencies and save them in the node_modules
folder. This folder ensures that all required dependencies are available for the project to run successfully.
Table of Content
- Introduction to node_modules Folder
- Purpose of node_modules
- Understanding NPM
- Understanding package.json
- Version Control with node_modules Folder
- Steps to Setup node_modules Folder
- Conclusion
Contact Us