Bootstrap your next project with npm init

Bootstrap your next project with npm init

With the latest npm versions, you can trigger npx with npm init.

Try it out with:

npm init react-app

Basically behind the scene, npm init will run npx create-react-app

Based on that knowledge, let’s create a bootstrapper package and deploy it to the npm registry.

The bootstrapper I decided to create is for open-source projects.

Features:

  • Run git init

  • Create license file

  • Create git ignore file

  • Create CODE_OF_CONDUCT.md

  • Run npm init -y

  • Add initial git commit.

The code: ( github)

Let’s pick a name for our package, we learned we need to prefix the name with create- and we are going to create package for open source project so the obvious name is going to be create-open-source.

For those who didn’t try to publish packages to the npm registry, you should sign up on npmjs.com and try npm publish in your project folder, make sure the name is unique.

Now let’s try it out:

mkdir new-project 
cd new-project 
npm init open-source

Originally published at niradler.com on April 16, 2019.