Starter template for prototyping and building CLI tools with Node.js and TypeScript

Why another starter template?

I created this template to help myself to build some simple tools and prototypes while learning Node.js, JavaScript and TypeScript. There are many guides on the web that show how to build a CLI tool with Node.js and TypeScript. However, I found them to be too complex for my needs.

That this template does not provide a way to bundle the app for distribution. It is meant to be used for learning and prototyping or for building tools that are not meant to be distributed.

Note: If you are looking for even better and more developer’s friendly way to develop simple tools and prototype check out Alternatives – Deno section of this article.

Code

The code is available on GitHub: https://github.com/kolorobot/vite-node-starter

Getting started

Adding new scripts

That’s it!

Dependencies

The project was created using Vite (yarn create vite ) and later modified to use Vite-Node and Vitest (and other dependencies).

Foundation

Support and utilities

How to update dependencies?

Alternatives – Deno

Deno is a free, open-source JavaScript and TypeScript runtime environment built on top of V8 JavaScript engine. It was created as an alternative to Node.js and aims to provide a more secure and efficient runtime experience for developers. Unlike Node.js, Deno does not require a package manager for installing third-party modules and includes built-in support for modern web development tools such as WebSockets, HTTP/HTTPS servers, and testing frameworks. Additionally, Deno aims to address some of the security concerns present in Node.js by offering a more secure sandboxed environment for executing scripts.

Deno can run JavaScript or TypeScript out of the box with no additional tools or config required. Here are the steps to get you started:

const name = Deno.args[0] || "World";
console.log(`Hello, ${name}!`);

Note, to support Deno in your IDE, such as Visual Studio Code or IntelliJ IDEA, you need to install appropriate extension:

Published on Java Code Geeks with permission by Rafal Borowiec, partner at our JCG program. See the original article here: Starter template for prototyping and building CLI tools with Node.js and TypeScript

Opinions expressed by Java Code Geeks contributors are their own.

Exit mobile version