Node 创建工程步骤

1. express


npm install -g express-generator

express myExpressApp

cd myExpressApp
npm install

npm start



http://localhost:3000

在当前NodeJs项目中添加TypeScript的支持

2.添加tsconfig.json,配置TypeScript 的编译输出

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


3. 添加tasks.json,添加编译命令和任务

{
	// 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. 在app.js中编写TS代码

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

猜你喜欢

转载自37235798.iteye.com/blog/2400804