rfcs icon indicating copy to clipboard operation
rfcs copied to clipboard

RFC: add preferDev field to package.json

Open Ginden opened this issue 4 years ago • 4 comments

Certain packages are used almost exclusively for development. Eg. typescript, tslint etc. It's usually a mistake to add them as normal dependencies.

I suggest to add field "preferDev": boolean (with default false) to package.json. User can't install preferDev package as production package without specifying --save-prod flag.

References

npm/cli#1337

Ginden avatar Nov 03 '20 13:11 Ginden

eslint presumably would preferDev, but it’s a runtime dep in standard, for example. I’m not sure package authors have sufficient context to know whether their package needs to be dev or prod.

ljharb avatar Nov 04 '20 19:11 ljharb

If this goes the direction of a warning, I would think you only show it on explicit package installs:

npm i eslint --save-prod

and not:

npm i

wesleytodd avatar Nov 04 '20 19:11 wesleytodd

My comments on this are essentially the same as my comments on preferPeer, for all the same reasons.

isaacs avatar Nov 25 '20 19:11 isaacs

Also making sure that is appears as the default install suggestion on NPM would be convenient!

npm-change-default-install-recomendation

Using the format npm i [package-name] -D for example.

Reddit: How To Change The Default Install Suggestion On NPM

RilDev avatar Dec 04 '20 09:12 RilDev