Node create project steps

1. express


npm install -g express-generator

express myExpressApp

cd myExpressApp
npm install

above sea level start



http://localhost:3000

Add TypeScript support in the current NodeJs project

2. Add tsconfig.json to configure the compilation output of TypeScript

{
	"compilerOptions": {
		"target": "es5",
		"module": "commonjs",
		"watch": false,
		"sourceMap": true,
		"outDir": "./out"
	},
	"exclude": [
		"node_modules",
		"out"
	]
}


3. Add tasks.json, add compile commands and tasks

{
	// See https://go.microsoft.com/fwlink/?LinkId=733558
	// for the documentation about the tasks.json format
	"version": "0.1.0",
	"command": "tsc",
	"isShellCommand": true,
	"args": ["-p", "."],
	"showOutput": "always",
	"problemMatcher": "$tsc"
}


4. Write TS code in app.js

var http=require('http');  
console.info(http);  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326460685&siteId=291194637