Npm has a fantastic init tool for creating the descriptor for your project. It will gladly provide defaults for you. These are sometimes helpful. Wouldn’t it be more better to define your own defaults?
package.json for your project. To get this file, you can edit it by hand or have one generated for you. To generate it, run:
You will then be prompted to answer a series of relevant questions, such as:
1 2 3 4 5 6 7 8 9 10
The values in parenthesis are the defaults. Defaults are determined from things like the directory you’re in, the git repository you’re in, etc.
Set Npm Init Defaults
Some defaults are just the NPM-provided conventions. They don’t know much more to provide. But you can provide your own defaults for your system by editing
~/.npmrc. Or you can use the cli to add to this file from the terminal. For instance, the two I like to change are my author name and the license:
Now, you can init and just take the defaults without pressing enter to answer the question with:
And what you get are the defaults you’ve already decided you like.
To know what other things you can change as defaults, use
npm help 7 config and grep for
init--prefixed values. Happy npm’ing!