Table of contents
Hi, I'm Subham Maity, a software engineer. I also enjoy teaching others how to code through my tutorials. I'm always eager to learn new things and share my knowledge with the community.
⚡ I recently wrote an article on What is Nodemon Package and wanted to share it with you all. You can find the article on my website https://codexam.vercel.app/docs/node/node1 [Better View]
⚡ I also have a repository on GitHub where you can find all the code and projects related to this topic. You can find the repository at https://github.com/Subham-Maity/node-js-full-stack-tutorial
❗ For a more in-depth look at this topic, including a detailed table of contents, check out the complete tutorial on my GitHub Repo
If you want to stay updated with my latest projects and articles, you can follow me on:
Suppose you made a change in your code and you want to see the changes in your browser. You have to stop the server and start it again. This is a very time-consuming process. So, to avoid this, we use the nodemon package. Nodemon is a package that automatically restarts the node application when file changes in the directory are detected.
⭐ How to Install Nodemon Package
- First, search for the nodemon package in the npm website. Then, click on the link to go to the npm website.
Copy the installation command from the npm website
npm i nodemon
If you add
-g
at the end of the command, it will install the package globally. So you can use it in any project.npm i nodemon -g
If you are using mac or linux you have to add
sudo
before the command.sudo npm i nodemon -g
Now, open your terminal and go to the project directory. Then, paste the command in the terminal and press enter.
Now, you can see the nodemon package in the package.json file.
Now you can use the nodemon package in your project. You can use the nodemon package in two ways.
- You can use the nodemon package in the package.json file. You can add the nodemon package in the
scripts
section of the package.json file. Then, you can use the nodemon package by running the commandnpm run dev
.
{
"scripts": {
"start": "node app.js",
"dev": "nodemon app.js"
},
}
- You can use the nodemon package in the terminal. You can use the nodemon package by running the command
nodemon app.js
ornodemon app.js -e js,html,css
(if you want to use nodemon for multiple file types).
- Now if you make any changes in your code, nodemon will automatically restart the server.