Aral Balkan

Mastodon icon RSS feed icon

npm init using

Want to download a git repository to use as a starting point for your own Node.js app but you don’t want to clone the repository?

Try this:

npm init using <github-account>/<starter-project-name> <my-project>

What that will do is download the specified repository into the my-project directory on your local machine.

Then, you can just:

cd my-project
npm install

And you’re off!

For example, to start using the Site.js starter template for Vite + Svelte, do:

npm init using small-tech/site-vite-svelte my-site

How it works

Under the hood, this uses a tiged, a community-maintained forked of degit (see what they did there?) that I then subsequently forked and renamed to create-using.

The way npm init works, npm init something gets translated to npx create-something, which in turn downloads and runs the create-something module from npm, which is supposed to, well, create something.

In this case, create-using (being tiged) downloads and extracts the tarball of the referenced git repository on GitHub (other hosts are also supported) to the local directory you specify.

So, basically it’s a little hack so we can have more expressive syntax.

If you don’t care for such things, you can do exactly the same thing using tiged directly:

npx tiged small-tech/site-vite-svelte my-site

Personally, I’d rather remember npm init using but you do whatever floats your boat. Heck, you can even go old-skool and just clone the repository using git like some sort of cavaman! 😛️

Like this? Fund us!

Small Technology Foundation is a tiny, independent not-for-profit.

We exist in part thanks to patronage by people like you. If you share our vision and want to support our work, please become a patron or donate to us today and help us continue to exist.