Q: Mark package as `private` from CLI? Is there a way to quickly mark an npm package as private instead of manually editing the package.json afterward?
Something like this:
npm --set-private true


A: Not that I am aware of, npm config set <key> <value> is used to set npm related configuration values for your .npmrc file. However, in order to change the values of the fields within your package.json you would have to use a CLI tool for working with JSON, something like json.
You can install json by doing the following: 
npm install -g json

Then for any node project that you wish to make the private field true you could do something along the lines of:
json -I -f package.json -e 'this.private=true'

or if you want to install the package locally do this instead:
./node_modules/.bin/json -I -f package.json -e 'this.private=true'

NOTE: For Window users please use double quotes and escape when necessary, an example of this is here:
Hopefully that helps!

A: I also found that using Yarn, I can mark the package as private right when creating it:
yarn init --private

which proves to be useful for new packages.
