Last active
September 10, 2020 08:10
-
-
Save robozavri/c775c062955c10e2de4bd8a134b7da64 to your computer and use it in GitHub Desktop.
#node.js typescript #typescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd server/ | |
npm init --yes | |
npm i express | |
import express from 'express'; | |
// const express = require('express'); | |
// rest of the code remains same | |
const app = express(); | |
const PORT = 8000; | |
app.get('/', (req: any, res: any) => res.send('Express + TypeScript Server')); | |
app.listen(PORT, () => { | |
console.log(`Server is running at http://localhost:${PORT}`); | |
}); | |
/* | |
tsc index.ts და გადაიყვანს ჯავასცრიპტში | |
tsc index.ts -w ჩაირთვება watch mode | |
*/ | |
npm i -D @types/node @types/express nodemon typescript ts-node | |
tsc --init | |
// need set "outDir": "./dist", AND "rootDir": "./src", AND uncomment "moduleResolution": "node", to tsconfig.json | |
package.json: | |
"scripts": { | |
"start": "node dist/index.ts", | |
"dev": "nodemon src/index.ts", | |
"build": "tsc -p ." | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment