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

Viewed 10004

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.

2 Answers

I think you should add it to dependencies just in case you use it to run your application by some package.json defined script:

"scripts": {
"develop": "nodemon src/server"

So it works for any develop who runs: npm run develop

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!

Related