node-infinity
v1.0.7
Published
This is a **Node+Express+Typescript** StarterPack
Downloads
9
Readme
Create Node Project
This is a Node+Express+Typescript StarterPack
Step 1:
npm init -yStep 2:
npm install --save-dev typescriptStep 3:
npx tsc --initStep 4: Add this data in tsconfig.json
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"rootDir": "./src",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}Step 5:
npm install expressStep 6:
npm install --save-dev ts-node nodemon @types/express @types/nodeStep 7: Create a src folder and create index.ts file inside it. And add this code in index.ts file.
import express from 'express';
const app = express();
const port = 3000;
app.get('/', (req, res) => {
res.send('Hello, World!');
});
app.listen(port, () => {
return console.log(`Express server is listening at http://localhost:${port} 🚀`);
});Step 8: Add this code in scripts section of package.json
"start": "tsc && node dist/index.js",
"dev": "nodemon src/index.ts"Step 9: Run this command to run the project
npm run dev