MelindaH26 / Quote-API

This project was created for practicing express.js and APIs as part of the Codecademy Backend-Engineer course.
0 stars 1 forks source link

Get Nodemon to work #1

Open MelindaH26 opened 9 months ago

MelindaH26 commented 9 months ago

Get Nodemon to work in the dev environment so that the server doesn't have to be restarted every time a change is made to the code.

nikhil3113 commented 9 months ago

hello @MelindaH26 i have solution, can i make a PR?

Shoetan commented 9 months ago

since you have nodemon installed as a dependency all you need to do is go to your package json, look for the scripts and do two things.

  1. Modify the start command to "scripts": { "start": "nodemon server.js" }

    1. Or write a new script "scripts": { "start": "node server.js", "dev": "nodemon server.js" }
MelindaH26 commented 8 months ago

@nikhil3113 Yes, of course!

@Shoetan Thank you! I am not overly familiar with json scripts yet. Does your second example mean that the server could either be started with start npm run start or npm run dev?

Shoetan commented 8 months ago

Yes you are right. You can have both scripts. Just know if you use node server.js any change to your code you will have to kill and restart your server. If you use nodemon server.js there's no need for that.

MelindaH26 commented 8 months ago

Great, thank you for the tips @Shoetan!

Shoetan commented 8 months ago

You're welcome @MelindaH26