Exploring a few Node.js api
-
Install Node.js
-
npm init
-
npm install express --save
-
npm install nodemon eslint typescript @types/node ts-node --save-dev
-
Configure eslint
npx eslint --init
-
Configure TypeScript
npx tsc --init
-
Configure
rootDir
andoutDir
intsconfig.json
"rootDir": "./src", "outDir": "./dist",
-
Configure nodemon for TS support by creating
nodemon.json
{ "watch": ["src"], "ext": "ts", "exec": "ts-node ./src/index.ts" }
-
Add the following scripts in
package.json
"scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "nodemon src/index.ts", "build": "tsc", "start": "node dist/index.js" },
-
Create a file named
index.ts
-
Run with
npm run dev