6

If you accidentally execute npm i npm it adds npm as a dependency to the package.json and adds entries to the package-lock.json.

Should I revert this? Or does it actually make sense to have npm as dependency in the package.json?

el-lugy
  • 378
  • 2
  • 15
  • 6
    Unless you're `require()`ing `npm`, no. – SLaks Jun 10 '18 at 18:50
  • Possible duplicate of https://stackoverflow.com/questions/50399097/is-it-okay-to-include-npm-in-devdependencies-in-package-json – Estus Flask Jun 10 '18 at 18:58
  • Is there a way to require a minimum npm version in my dev team? I thought maybe having npm in package.json might do this. – el-lugy Jun 10 '18 at 19:09
  • @el-lugy Is there a reason you need a particular version of NPM? A lot of people don't even use NPM, they use Yarn and such... – Brad Jun 10 '18 at 19:30

2 Answers2

5

npm or other package managers are meant to be installed globally.

If you wish to specify the minimum npm version for your project, you could add this to package.json

"engines" : {
  "npm" : ">=x.x.x"
}
kit
  • 535
  • 4
  • 10
-1

No, you don't need to have NPM as the dependency in package.json file.

Harshal Yeole
  • 4,812
  • 1
  • 21
  • 43