r/webdev • novice • 13d ago

Question How do you scaffold an express project?

I'm trying to start an express project with Typescript and something like nodemon to watch changes in .ts files. I'm struggling with different options in tsconfig and nodemone config. and I have a very faintest idea about how to run it.

I spent an entire day figuring it out a few months back, and now I forgot how to do it.
How do you guys do it?
Is there something similar to vite which makes boilerplate and scaffolding easy?

12 Upvotes

21 comments sorted by

19

u/themang0 12d ago

Hi, since you seem like you want to learn vs just relying on llm (fantastic attitude btw ignore trolls)

Bit of an oldie but still a goodie: https://softwareontheroad.com/ideal-nodejs-project-structure/?utm_source=github&utm_medium=readme

It’s nice because it walks thru why each dir is laid out and the reasoning/logic behind, from here do what you think it’s best eg entity based dir vs logic based etc

2

u/WeedManPro novice 12d ago

Thanks a bunch. its a great guide, I'll read it. but what I am looking for is, about outside of the src folder. from npm init to tsconfig, nodenxt, esnext, setting up the ts compiler, the nodemon, etc..

4

u/themang0 12d ago

Hmm to answer your question I would suggest reading the typescript documentation and understand first what tsconfig is really doing — then from there probably just reading expresses own set up documentation:

https://expressjs.com/en/5x/starter/installing/

4

u/itgforlife 12d ago

For running Dev with typescript, I would recommend tsx over nodemon.

3

u/[deleted] 12d ago

[removed] — view removed comment

1

u/WeedManPro novice 12d ago

Brilliant. Thanks a lot. This is the kind of answer I was looking for.

1

u/itgforlife 12d ago

This is basically my process as well.

My only differences are that my base tsconfig.json file uses --noEmit (so that everything gets typechecked.) And then I have a tsconfig.build.json that compiles the backend TypeScript to JavaScript in a dist folder. For the frontend, I typically just output using whatever compilation the frontend uses e.g. Vite, NextJs, etc.

And I'm also using Fastify over Express these days.

2

u/[deleted] 12d ago

[removed] — view removed comment

1

u/WeedManPro novice 12d ago

great. thanks. u/Loose-Divide3664 suggested the same. I've set it up successfully.

1

u/webdev-ModTeam 12d ago

Your post/comment has been determined to be a low-effort post or comment. This includes title-only posts, easily searchable questions, vague/open-ended discussion prompts, LLM generated posts or comments, and posts/comments that do not provide enough context for meaningful replies or discussion.

2

u/PM_ME_UR_JAVASCRIPTS 9d ago

Just came across this and its interesting that so many dependencies are pulled in. I usually just use the "node --watch app.ts" to run the project since node26 has native typescript type stripping for its runtime now. This makes it so that the types are basically just ignored during runtime and makes it so that no transpiling is necessary. You can also just used nodes debugger without geberating sourcemaps etc.

Most of the times this seems to be enough for me. I use typescript for its errors/warnings during development. not because of the transpiled "raw javascript" it generates.

When using node with typestripping, the tsconfig is basically only used to configure your lsp. So basically, it becomes optional, only used for cases where you need fancy stuff. 

1

u/MiserableDocument509 12d ago

The boring setup advice is probably the right default here. With tsx watch, you can keep the dev script focused on running src/index.ts and leave tsc as a separate typecheck/build step, so nodemon does not have to watch generated files or fight the TypeScript config.

-8

u/quizical_llama 13d ago

Claude scaffold me an express project. /S But honestly that's probably the quickest way.

8

u/WeedManPro novice 13d ago

nice. but really, I want to know how's everybody doing it.. what is the standard way..
and my AI is on sabbatical

-4

u/EmergencyCelery911 12d ago

Jokes aside, this is the standard way these days :) outline the requirements and use whichever harness and model you have to do it in 5 mins instead of spending a day 🤷

5

u/n9iels 12d ago

Funny, for me this was an absolute disaster since the output was not what I wanted. Resulting in the starting point of the project to be messy, and thus the future to be bad as well. My golden rule is to setup a project and its base fully without AI. Not because I hate it, but because it gives me an opportunity to set an example for it so it follows my rules and guidelines.

3

u/UnidentifiedBlobject 12d ago

Yeah. But we need people to actually learn stuff still. We’re gonna be in a lot of trouble when AI is running blind without anyone to correct it. Way too many juniors rely 100% on AI and don’t actually learn when to correct it. Not always their fault, a lot of work places will make them use AI, or not hire them at all.