Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I add nodemon as a dev dependency on my project even if I already installed it as a global dependency?

Tags:

node.js

npm

I'm learning basic node.js and realized that I can use a package installed globally on my pc without installing it in my project.

Currently my dependencies look like this:

"dependencies": {
    "cookie-parser": "~1.4.4",
    "debug": "~2.6.9",
    "express": "~4.16.1",
    "http-errors": "~1.6.3",
    "morgan": "~1.9.1",
    "pug": "2.0.0-beta11"
  },
  "devDependencies": {
    "jasmine": "^3.6.1"
  }

I was using nodemon but just realized that it's not listed as a dev dependency, should I add it with npm i --save-dev nodemon as a good practice?

I guess it must be declared as dependency in case this was a collaborative project but I'm not sure.

like image 698
Chefcito Avatar asked Aug 14 '20 08:08

Chefcito


People also ask

Is Nodemon as Dev dependency?

When performing a local installation, you can install nodemon as a dev dependency with --save-dev (or --dev ). Install nodemon locally with npm : npm install nodemon --save-dev.

Do I have to install Nodemon globally?

Install Nodemon I assume you have Node. js and NPM installed. You can install Nodemon on your machine, globally, or locally on your project using NPM.

Do you need Nodemon in production?

When working locally on a NodeJS project, nodemon is required in order to make the coding easier.


Video Answer


1 Answers

If you install nodemon as a Dev dependency, then it will not be locally installed, it'll not be available in your system path. But if you install nodemon globally then it'll be installed on your system path globally.

To install nodemon globally:

npm install -g nodemon

To install nodemon as a dev dependecy:

npm install --save-dev nodemon

Thanks!

like image 170
Manpreet Singh Avatar answered Nov 15 '22 00:11

Manpreet Singh