https://github.com/emanuelefavero/node-typescript
A boilerplate and quick start guide for building Node.js applications using TypeScript
https://github.com/emanuelefavero/node-typescript
boilerplate eslint guide node node-typescript nodejs nodejs-typescript quickstart typescript
Last synced: 8 months ago
JSON representation
A boilerplate and quick start guide for building Node.js applications using TypeScript
- Host: GitHub
- URL: https://github.com/emanuelefavero/node-typescript
- Owner: emanuelefavero
- License: mit
- Created: 2025-03-30T22:35:35.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-04-08T16:49:11.000Z (8 months ago)
- Last Synced: 2025-04-08T17:43:20.463Z (8 months ago)
- Topics: boilerplate, eslint, guide, node, node-typescript, nodejs, nodejs-typescript, quickstart, typescript
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Node.js TypeScript Quick Start Boilerplate
This is a boilerplate and quick start guide for building Node.js applications using TypeScript. It includes a basic project structure, configuration files, and linting rules to help you get started quickly.
## Features
- Node.js TypeScript support
- ESLint for linting
## Installation
- Clone the repository
- Run `npm install` to install dependencies
- Run `npm run dev` to start the development server
- Edit the `index.ts` file inside `src` to start building your application
> Tip: You can also use `npm run build` to build the project for production and `npm start` to run the built project
>
> BEWARE: If you use `prettier`, make sure the `eslint` rules do not conflict with it
## Quick Setup for a new Node.js TypeScript project
- Create an `npm` project
```bash
npm init -y
```
- Add a `.gitignore` file (use `.gitignore` from this repo)
- Create an `index.ts` file in the root directory
- Install TypeScript, ts-node and nodemon
```bash
npm install --save-dev typescript ts-node @types/node nodemon
```
- Add a `tsconfig.json` file
```json
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"outDir": "./dist",
"rootDir": "./src"
}
}
```
> Note: you can also generate one using the `npx tsc --init` command
- Add these scripts to your `package.json` file
```json
"scripts": {
"dev": "nodemon --watch src --exec ts-node src/index.ts",
"build": "npx tsc",
"start": "node dist/index.js",
"lint": "eslint --ext .ts ."
},
```
### Optional ESLint Setup
- Install ESLint for TypeScript
```bash
npm install --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
```
- Setup ESLint
```bash
npx eslint --init
```
> Note: During the ESlint setup process, remember to also turn on `node` besides `browser` using the `space` bar when selecting the environment
## References
- [Node.js](https://nodejs.org/en/)
- [TypeScript](https://www.typescriptlang.org/)
- [ESLint](https://eslint.org/)
- [Prettier](https://prettier.io/)
- [Nodemon](https://nodemon.io/)
- [ts-node](https://typestrong.org/ts-node/)
## License
- [MIT](LICENSE.md)