naveen chandru
naveen chandru

Reputation: 108

Is it okay to include npm in devdependencies in package.json?

I came across a nodejs repo that included npm in devdependencies. What would be the case that requires such config? Because, installing devdependencies already requires npm.

Upvotes: 1

Views: 1009

Answers (2)

Estus Flask
Estus Flask

Reputation: 222379

This makes sense if a repository uses NPM CLI internally and relies on specific NPM version instead of globally installed NPM, because the behaviour may be changed between major releases:

devDependencies: {
  "npm": "^2"
}

While

devDependencies: {
  "npm": "*"
}

won't make much sense, except that it will likely use latest stable NPM version, despite which version was installed globally on local system.

This also makes sense if NPM is used programmatically because global packages cannot be normally required.

Upvotes: 3

Ashok JayaPrakash
Ashok JayaPrakash

Reputation: 2293

Modules which is required for your local development and does not required for production environment can be listed under devDependencies. Its is good to have devDependencies.

  • npm install will install both "dependencies" and "devDependencies"
  • npm install --production will only install "dependencies"
  • npm install --dev will only install "devDependencies"

Upvotes: 0

Related Questions