The Lazy Person's NPM Init

If you're like me, when you set up a new NodeJS project, you use the npm init command.

$ npm init

This command creates a package.json file with some fields so you can begin adding dependencies for your application.

When you do this however, the command prompts you to input information about your project so it can populate some of the fields in the package.json file. If you're like me though you probably just press enter multiple times to have NPM use the default value for each field.

Well, if you'd like to save yourself the extreme and onerous task of pressing enter 10 times to merely have a skeleton package.json file, you should use the yes command. The yes command was made for repetitive inputs like this, where one needed to enter 'y' multiple times in a row.

To use this command with npm init, simply pipe yes's output to npm init

$ yes '' | npm init

Now you don't have to press enter so many times :)

* Note, by default the yes command outputs 'y' followed by a newline. Giving it the argument of an empty string ('') will tell it to merely output the newline.