Follow these steps to set up your project:
-
Initialize a new npm project:
npm init -y
-
Install TypeScript as a development dependency:
npm i -D typescript
-
Install ts-node as a development dependency:
npm i -D ts-node
-
Install nodemon as a development dependency:
npm i -D nodemon
-
Create a
tsconfig.jsonfile with the following content:{ "compilerOptions": { "module": "NodeNext", "moduleResolution": "NodeNext", "baseUrl": "src", "outDir": "dist", "sourceMap": true, "noImplicitAny": true }, "include": ["src/**/*"] } -
Create a
nodemon.jsonfile with the following content:{ "watch": ["src"], "ext": ".ts,.js", "exec": "ts-node ./src/index.ts" } -
Create a folder named
srcand add anindex.tsfile inside it. -
Add the following line to the
scriptssection of yourpackage.json:"start": "nodemon"
-
Run the project:
- Add a
console.log("something")statement inindex.ts. - Start the project by running:
npm start
- Add a
This will verify that the project is set up correctly.