This project is a basic setup for developing a Node.js application using TypeScript, ts-node, and nodemon for automatic restarts during development.
Ensure you have Node.js installed. You can download it from nodejs.org.
-
Clone the repository:
git clone https://github.com/ferrymehdi/ts-setup.git cd ts-setup
-
Install the dependencies:
npm install
ts-setup/
├── src/
│ └── index.ts
├── .gitignore
├── nodemon.json
├── package.json
├── tsconfig.json
└── README.md
tsconfig.json
: TypeScript configuration file.nodemon.json
: Nodemon configuration file.
npm run build
: Compiles TypeScript files to JavaScript.npm run dev
: Runs the project in development mode with nodemon and ts-node.npm start
: Runs the project directly using ts-node.
-
Development Mode:
npm run dev
This will start the project with nodemon, which will watch for changes in the
src
directory and automatically restart the server. -
Production Mode:
npm run build npm start
This will compile the TypeScript files into the
dist
directory and run the compiled JavaScript files.
You can find the example TypeScript code in src/index.ts
:
const sayHello = (name: string): string => {
return `Hello, ${name}!`;
};
console.log(sayHello("World"));
This project is licensed under the ISC License.