npm init command is the simplest way to start a project, but filling answers to those questions are irritating. If we use
npm init -y it will skip all the questions, but it will generate the
package.json with npm default values. We have to update the author details, version and license later.
To make this easier we can set the author details, starting version and our favorite license in the
.npmrc file so that next time we do
npm init -y instead of npm default npm use
.npmrc and fill the details.
We can use the
npm config command to set those values to our global
npm config set init-author-name "Your name" npm config set init-author-email "firstname.lastname@example.org" npm config set init-author-url "http://example.com/" npm config set init-license "MIT"
.npmrc will have these configuration
init-author-name=Your name email@example.com init-author-url=http://example.com/ init-license=MIT
Next time when we do
npm init -y this will set the author name as “Your name”, email as “firstname.lastname@example.org”, url as “http://example.com/” and license as “MIT”.
For more details on npm config check the official doc
Hope it helped.
Let me know if you have any feedback or corrections via comments