create-program v1.0.0
create-program
This is a scaffolding tool to create a simple Node.js program written in TypeScript, utilizing ECMAScript Modules (ESM) and using Jest as a test suite. The tool came out of my own frustration with setting all this up, and can be used for starting up simple command-line apps, or any Node.js app really.
(A "program" is what we used to call "apps" back in the day. And yeah, create-app was taken.)
Usage
Create a directory for your project and run the following command in it:
npm create programYou can also specify the directory where it will be created.
npm create program --path ~/code/my-new-projectIt will use the directory name as the project name, but you can specify a different name with the --name option.
npm create program --name name-of-my-new-projectFor other options, run:
npm create program --helpAlternative approaches
The Node.js documentation has a getting started page for how to set up a TypeScript project. There they mention the usage of the
--loaderflag, likenode --loader=ts-node/esm example.ts, I have a working example here – however, this prints a nasty warning that this flag is experimental and might be removed in the future. Instead, there is an--importflag that should be used. This is being discussed in this issue. I have a working example of how to get this variant working here.I am not sure if this kind of approach is really worth it, and the
ts-nodeproject seems to not be very actively maintained.node-typescript-boilerplate is a nice and updated boilerplate project, which I took some inspiration from.
- Using TypeScript Node.js with native ESM is a good reference guide on how things should be set up.
- Other "project starter" kind of things are here.
- I have understood that other JavaScript runtimes like Deno and Bun simplify a lot of this process, if you don't have the requirement of sticking with Node.js.
- Obviously, there are many "starter" kind of projects for more full fledged applications using a particular framework, like create-react-app (which I think is pretty much abandoned, though), create-next-app, create-vite and so on. For CLI apps, you can also try oclif.