Automate creating projects with npm initializers

Speed up your development workflow using npm initializer packages - even write your own!
2020-07-11

Want to speed up your development workflow? 🚀

What if you could automate creating new projects? 🤖

Like create-react-app ⚛️ but what about for other kinds of projects?

You’re probably familiar with this tedious process 😞 - and it’s especially tedious for monorepos!

  • npm init my-app
  • cd my-app
  • npm add whatever
  • npm add -D lerna @babel/code @babel/preset-env
  • mkdir src
  • touch src/index.js
  • touch babel.config.js
  • mkdir packages
  • mkdir packages/one
  • mkdir packages/two
  • code .
  • Edit babel.config.js
  • etc.

Well, good news! 🎉

It turns out npm init has a feature where it can execute “initializer” packages named create-* on npm.

So all you have to do is just run a command like:

$ npm init babel my-app

This will create your project based on the script in the package create-babel.

So naturally, I’ve created several of my own initializers:

You can find more of mine at on GitHub.

If you dig into the source, you’ll notice many of initializers use my utility base-create that makes it easier to write them. I also wrapped that in base-create-monorepo to help write them for monorepos.

And there’s a healthy, open-source community with many more initializers availabile! Try searching for create-* on npm.

Onward & upward! 🚀