Search code examples
node.jsnpm

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


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.


Solution

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

    "scripts": {
      "dev": "nodemon src/server.js"
    },
    

    So it works for any developer who runs: npm run dev